Parent

Rack::Attack::Cache

Attributes

prefix[RW]
store[R]

Public Class Methods

new() click to toggle source
# File lib/rack/attack/cache.rb, line 7
def initialize
  self.store = ::Rails.cache if defined?(::Rails.cache)
  @prefix = 'rack::attack'
end

Public Instance Methods

count(unprefixed_key, period) click to toggle source
# File lib/rack/attack/cache.rb, line 17
def count(unprefixed_key, period)
  epoch_time = Time.now.to_i
  expires_in = period - (epoch_time % period)
  key = "#{prefix}:#{(epoch_time/period).to_i}:#{unprefixed_key}"
  do_count(key, expires_in)
end
read(unprefixed_key) click to toggle source
# File lib/rack/attack/cache.rb, line 24
def read(unprefixed_key)
  store.read("#{prefix}:#{unprefixed_key}")
end
store=(store) click to toggle source
# File lib/rack/attack/cache.rb, line 13
def store=(store)
  @store = StoreProxy.build(store)
end
write(unprefixed_key, value, expires_in) click to toggle source
# File lib/rack/attack/cache.rb, line 28
def write(unprefixed_key, value, expires_in)
  store.write("#{prefix}:#{unprefixed_key}", value, :expires_in => expires_in)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.