Class: Rack::ApiKeyLimit::Cache::Redis
- Inherits:
-
Object
- Object
- Rack::ApiKeyLimit::Cache::Redis
- Defined in:
- lib/rack_api_key_limit/cache/redis.rb
Instance Method Summary collapse
- #get(key) ⇒ Object
- #increment(key, limit_seconds) ⇒ Object
-
#initialize(redis) ⇒ Redis
constructor
A new instance of Redis.
Constructor Details
#initialize(redis) ⇒ Redis
Returns a new instance of Redis.
5 6 7 |
# File 'lib/rack_api_key_limit/cache/redis.rb', line 5 def initialize(redis) @redis = redis end |
Instance Method Details
#get(key) ⇒ Object
9 10 11 |
# File 'lib/rack_api_key_limit/cache/redis.rb', line 9 def get(key) @redis.get(key) end |
#increment(key, limit_seconds) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rack_api_key_limit/cache/redis.rb', line 13 def increment(key, limit_seconds) @redis.multi do @redis.incr(key) @redis.expire(key, limit_seconds) end end |