mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
fix: Do not attempt to process Memcache clients with DalliProxy
This commit is contained in:
parent
397a7ce7b4
commit
faa0638719
3 changed files with 11 additions and 5 deletions
|
|
@ -3,5 +3,6 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gem "activesupport", "~> 3.2.0"
|
||||
gem "memcache-client"
|
||||
|
||||
gemspec :path => "../"
|
||||
|
|
|
|||
|
|
@ -8,11 +8,16 @@ module Rack
|
|||
# (method has an arity of 2; must call #expire separately
|
||||
if (defined?(::ActiveSupport::Cache::RedisStore) && store.is_a?(::ActiveSupport::Cache::RedisStore)) ||
|
||||
(defined?(::ActiveSupport::Cache::MemCacheStore) && store.is_a?(::ActiveSupport::Cache::MemCacheStore))
|
||||
# ActiveSupport::Cache::RedisStore doesn't expose any way to set an expiry,
|
||||
# so use the raw Redis::Store instead
|
||||
store = store.instance_variable_get(:@data)
|
||||
end
|
||||
|
||||
# ActiveSupport::Cache::RedisStore doesn't expose any way to set an expiry,
|
||||
# so use the raw Redis::Store instead.
|
||||
# We also want to use the underlying Dalli client instead of ::ActiveSupport::Cache::MemCacheStore,
|
||||
# but not the Memcache client if using Rails 3.x
|
||||
client = store.instance_variable_get(:@data)
|
||||
if client.is_a?(Redis::Store) || client.is_a?(Dalli::Client)
|
||||
store = store.instance_variable_get(:@data)
|
||||
end
|
||||
end
|
||||
klass = PROXIES.find { |proxy| proxy.handle?(store) }
|
||||
klass ? klass.new(store) : store
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ module Rack
|
|||
if defined?(::ConnectionPool) && store.is_a?(::ConnectionPool)
|
||||
store.with { |conn| conn.is_a?(::Dalli::Client) }
|
||||
else
|
||||
store.is_a?(::Dalli::Client) || store.is_a?(::ActiveSupport::Cache::MemCacheStore)
|
||||
store.is_a?(::Dalli::Client)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue