Parent

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
# File lib/rack/attack/store_proxy/redis_store_proxy.rb, line 11
def initialize(store)
  super(store)
end

Public Instance Methods

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)
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)
  else
    self.set(key, value)
  end
rescue Redis::BaseError
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.