class Rack::Attack::StoreProxy::DalliProxy
Public Class Methods
handle?(store)
click to toggle source
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 9 def self.handle?(store) return false unless defined?(::Dalli) # Consider extracting to a separate Connection Pool proxy to reduce # code here and handle clients other than Dalli. if defined?(::ConnectionPool) && store.is_a?(::ConnectionPool) store.with { |conn| conn.is_a?(::Dalli::Client) } else store.is_a?(::Dalli::Client) end end
new(client)
click to toggle source
Calls superclass method
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 21 def initialize(client) super(client) stub_with_if_missing end
Private Class Methods
with() { |__getobj__| ... }
click to toggle source
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 63 def with yield __getobj__ end
Public Instance Methods
delete(key)
click to toggle source
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 50 def delete(key) rescuing do with do |client| client.delete(key) end end end
increment(key, amount, options = {})
click to toggle source
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 42 def increment(key, amount, options = {}) rescuing do with do |client| client.incr(key, amount, options.fetch(:expires_in, 0), amount) end end end
read(key)
click to toggle source
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 26 def read(key) rescuing do with do |client| client.get(key) end end end
write(key, value, options = {})
click to toggle source
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 34 def write(key, value, options = {}) rescuing do with do |client| client.set(key, value, options.fetch(:expires_in, 0), raw: true) end end end
Private Instance Methods
rescuing() { || ... }
click to toggle source
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 70 def rescuing yield rescue Dalli::DalliError nil end
stub_with_if_missing()
click to toggle source
# File lib/rack/attack/store_proxy/dalli_proxy.rb, line 60 def stub_with_if_missing unless __getobj__.respond_to?(:with) class << self def with yield __getobj__ end end end end