class RateLimit::Memory

Public Class Methods

new() click to toggle source
# File lib/ratelimit/bucketbased.rb, line 82
def initialize
        @buckets = {}
end

Public Instance Methods

get(name) click to toggle source

retrieves a named bucket

  • Args :

    • name -> the name of the bucket to be retrieved

  • Returns :

    • the bucket matching the name if found, nil otherwise

# File lib/ratelimit/bucketbased.rb, line 91
def get(name)
        @buckets[name]
end
set(bucket) click to toggle source

saves a bucket into the storage

  • Args :

    • bucket -> the Bucket to set. The name field in the Bucket option will be used as a key.

  • Returns :

    • the bucket that is provided in the Args

# File lib/ratelimit/bucketbased.rb, line 100
def set(bucket)
        @buckets[bucket.name] = bucket
end
update(bucket) click to toggle source

updates the key fields that need updating into the storage this is often cheaper for certain types of storage than using set()

  • Args :

    • bucket -> the Bucket to update. The name field in the Bucket option will be used as a key.

  • Returns :

    • nil

# File lib/ratelimit/bucketbased.rb, line 110
def update(bucket)
        # already updated
end