diff --git a/lib/rack/attack.rb b/lib/rack/attack.rb index b1b07c5..d7c7252 100644 --- a/lib/rack/attack.rb +++ b/lib/rack/attack.rb @@ -18,7 +18,6 @@ class Rack::Attack autoload :Track, 'rack/attack/track' autoload :StoreProxy, 'rack/attack/store_proxy' autoload :DalliProxy, 'rack/attack/store_proxy/dalli_proxy' - autoload :MemCacheProxy, 'rack/attack/store_proxy/mem_cache_proxy' autoload :MemCacheStoreProxy, 'rack/attack/store_proxy/mem_cache_store_proxy' autoload :RedisProxy, 'rack/attack/store_proxy/redis_proxy' autoload :RedisStoreProxy, 'rack/attack/store_proxy/redis_store_proxy' diff --git a/lib/rack/attack/store_proxy.rb b/lib/rack/attack/store_proxy.rb index fdd0e23..bf9ec90 100644 --- a/lib/rack/attack/store_proxy.rb +++ b/lib/rack/attack/store_proxy.rb @@ -3,7 +3,7 @@ module Rack class Attack module StoreProxy - PROXIES = [DalliProxy, MemCacheStoreProxy, MemCacheProxy, RedisStoreProxy, RedisProxy, RedisCacheStoreProxy].freeze + PROXIES = [DalliProxy, MemCacheStoreProxy, RedisStoreProxy, RedisProxy, RedisCacheStoreProxy].freeze def self.build(store) client = unwrap_active_support_stores(store) diff --git a/lib/rack/attack/store_proxy/mem_cache_proxy.rb b/lib/rack/attack/store_proxy/mem_cache_proxy.rb deleted file mode 100644 index 8ed6583..0000000 --- a/lib/rack/attack/store_proxy/mem_cache_proxy.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -module Rack - class Attack - module StoreProxy - class MemCacheProxy < SimpleDelegator - def self.handle?(store) - defined?(::MemCache) && store.is_a?(::MemCache) - end - - def initialize(store) - super(store) - stub_with_if_missing - end - - def read(key) - # Second argument: reading raw value - get(key, true) - rescue MemCache::MemCacheError - end - - def write(key, value, options = {}) - # Third argument: writing raw value - set(key, value, options.fetch(:expires_in, 0), true) - rescue MemCache::MemCacheError - end - - def increment(key, amount, _options = {}) - incr(key, amount) - rescue MemCache::MemCacheError - end - - def delete(key, _options = {}) - with do |client| - client.delete(key) - end - rescue MemCache::MemCacheError - end - - private - - def stub_with_if_missing - unless __getobj__.respond_to?(:with) - class << self - def with; yield __getobj__; end - end - end - end - end - end - end -end