Class: Rack::Attack::StoreProxy::RedisStoreProxy

Inherits:
RedisProxy
  • Object
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

Constructor Details

This class inherits a constructor from Rack::Attack::StoreProxy::RedisProxy

Class Method Details

.handle?(store) ⇒ Boolean

Returns:

  • (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