Class: Grape::Attack::Adapters::Redis
- Inherits:
-
Object
- Object
- Grape::Attack::Adapters::Redis
- Defined in:
- lib/grape/attack/adapters/redis.rb
Instance Attribute Summary collapse
-
#broker ⇒ Object
readonly
Returns the value of attribute broker.
Instance Method Summary collapse
- #atomically(&block) ⇒ Object
- #expire(key, ttl_in_seconds) ⇒ Object
- #get(key) ⇒ Object
- #incr(key) ⇒ Object
-
#initialize ⇒ Redis
constructor
A new instance of Redis.
Constructor Details
#initialize ⇒ Redis
Returns a new instance of Redis.
10 11 12 |
# File 'lib/grape/attack/adapters/redis.rb', line 10 def initialize @broker = ::Redis::Namespace.new("grape-attack:#{env}:thottle", redis: ::Redis.new(url: url)) end |
Instance Attribute Details
#broker ⇒ Object (readonly)
Returns the value of attribute broker.
8 9 10 |
# File 'lib/grape/attack/adapters/redis.rb', line 8 def broker @broker end |
Instance Method Details
#atomically(&block) ⇒ Object
32 33 34 |
# File 'lib/grape/attack/adapters/redis.rb', line 32 def atomically(&block) broker.multi(&block) end |
#expire(key, ttl_in_seconds) ⇒ Object
26 27 28 29 30 |
# File 'lib/grape/attack/adapters/redis.rb', line 26 def expire(key, ttl_in_seconds) with_custom_exception do broker.expire(key, ttl_in_seconds) end end |
#get(key) ⇒ Object
14 15 16 17 18 |
# File 'lib/grape/attack/adapters/redis.rb', line 14 def get(key) with_custom_exception do broker.get(key) end end |
#incr(key) ⇒ Object
20 21 22 23 24 |
# File 'lib/grape/attack/adapters/redis.rb', line 20 def incr(key) with_custom_exception do broker.incr(key) end end |