class Rack::Attack::StoreProxy::RedisStoreProxy

Public Class Methods

handle?(store) click to toggle source
# 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
new(store) click to toggle source
Calls superclass method
# File lib/rack/attack/store_proxy/redis_store_proxy.rb, line 11
def initialize(store)
  super(store)
end

Public Instance Methods

delete(key, options={}) click to toggle source
# File lib/rack/attack/store_proxy/redis_store_proxy.rb, line 39
def delete(key, options={})
  self.del(key)
rescue Redis::BaseError
end
increment(key, amount, options={}) click to toggle source
# File lib/rack/attack/store_proxy/redis_store_proxy.rb, line 29
def increment(key, amount, options={})
  count = nil
  self.pipelined do
    count = self.incrby(key, amount)
    self.expire(key, options[:expires_in]) if options[:expires_in]
  end
  count.value if count
rescue Redis::BaseError
end
read(key) click to toggle source
# File lib/rack/attack/store_proxy/redis_store_proxy.rb, line 15
def read(key)
  self.get(key, raw: true)
rescue Redis::BaseError
end
write(key, value, options={}) click to toggle source
# File lib/rack/attack/store_proxy/redis_store_proxy.rb, line 20
def write(key, value, options={})
  if (expires_in = options[:expires_in])
    self.setex(key, expires_in, value, raw: true)
  else
    self.set(key, value, raw: true)
  end
rescue Redis::BaseError
end