Class: Rack::Attack::StoreProxy::RedisStoreProxy
- Inherits:
-
RedisProxy
- Object
- SimpleDelegator
- RedisProxy
- Rack::Attack::StoreProxy::RedisStoreProxy
show all
- Defined in:
- lib/rack/attack/store_proxy/redis_store_proxy.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from RedisProxy
#delete, #increment, #initialize
Class Method Details
.handle?(store) ⇒ Boolean
7
8
9
|
# File 'lib/rack/attack/store_proxy/redis_store_proxy.rb', line 7
def self.handle?(store)
defined?(::Redis::Store) && store.is_a?(::Redis::Store)
end
|
Instance Method Details
#read(key) ⇒ Object
11
12
13
14
|
# File 'lib/rack/attack/store_proxy/redis_store_proxy.rb', line 11
def read(key)
get(key, raw: true)
rescue Redis::BaseError
end
|
#write(key, value, options = {}) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/rack/attack/store_proxy/redis_store_proxy.rb', line 16
def write(key, value, options = {})
if (expires_in = options[:expires_in])
setex(key, expires_in, value, raw: true)
else
set(key, value, raw: true)
end
rescue Redis::BaseError
end
|