Class: RateLimit::Memory
- Defined in:
- lib/ratelimit/bucketbased.rb
Instance Method Summary collapse
-
#get(name) ⇒ Object
retrieves a named bucket * Args : -
name
-> the name of the bucket to be retrieved * Returns : - the bucket matching the name if found, nil otherwise. -
#initialize ⇒ Memory
constructor
A new instance of Memory.
-
#set(bucket) ⇒ Object
saves a bucket into the storage * Args : -
bucket
-> the Bucket to set. -
#update(bucket) ⇒ Object
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.
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
82 83 84 |
# File 'lib/ratelimit/bucketbased.rb', line 82 def initialize @buckets = {} end |
Instance Method Details
#get(name) ⇒ Object
retrieves a named bucket
-
Args :
-
name
-> the name of the bucket to be retrieved
-
-
Returns :
-
the bucket matching the name if found, nil otherwise
-
91 92 93 |
# File 'lib/ratelimit/bucketbased.rb', line 91 def get(name) @buckets[name] end |
#set(bucket) ⇒ Object
saves a bucket into the storage
-
Args :
-
bucket
-> the Bucket to set. Thename
field in the Bucket option will be used as a key.
-
-
Returns :
-
the bucket that is provided in the Args
-
100 101 102 |
# File 'lib/ratelimit/bucketbased.rb', line 100 def set(bucket) @buckets[bucket.name] = bucket end |
#update(bucket) ⇒ Object
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. Thename
field in the Bucket option will be used as a key.
-
-
Returns :
-
nil
-
110 111 112 |
# File 'lib/ratelimit/bucketbased.rb', line 110 def update(bucket) # already updated end |