mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-25 14:47:43 +00:00
Merge pull request #387 from grzuy/fix_redis_3_and_memory_store
[Fixes #355] Fix unexpected error when using redis 3 and any store which is not proxied
This commit is contained in:
commit
014f74b95d
6 changed files with 17 additions and 3 deletions
|
|
@ -19,6 +19,7 @@ gemfile:
|
||||||
- gemfiles/rails_4_2.gemfile
|
- gemfiles/rails_4_2.gemfile
|
||||||
- gemfiles/dalli2.gemfile
|
- gemfiles/dalli2.gemfile
|
||||||
- gemfiles/redis_4.gemfile
|
- gemfiles/redis_4.gemfile
|
||||||
|
- gemfiles/redis_3.gemfile
|
||||||
- gemfiles/connection_pool_dalli.gemfile
|
- gemfiles/connection_pool_dalli.gemfile
|
||||||
- gemfiles/active_support_redis_cache_store.gemfile
|
- gemfiles/active_support_redis_cache_store.gemfile
|
||||||
- gemfiles/active_support_redis_cache_store_pooled.gemfile
|
- gemfiles/active_support_redis_cache_store_pooled.gemfile
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,10 @@ appraise 'redis_4' do
|
||||||
gem 'redis', '~> 4.0'
|
gem 'redis', '~> 4.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
appraise 'redis_3' do
|
||||||
|
gem 'redis', '~> 3.3'
|
||||||
|
end
|
||||||
|
|
||||||
appraise "connection_pool_dalli" do
|
appraise "connection_pool_dalli" do
|
||||||
gem "connection_pool", "~> 2.2"
|
gem "connection_pool", "~> 2.2"
|
||||||
gem "dalli", "~> 2.7"
|
gem "dalli", "~> 2.7"
|
||||||
|
|
|
||||||
9
gemfiles/redis_3.gemfile
Normal file
9
gemfiles/redis_3.gemfile
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# This file was generated by Appraisal
|
||||||
|
|
||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
gem "redis", "~> 3.3"
|
||||||
|
|
||||||
|
gemspec path: "../"
|
||||||
|
|
@ -7,7 +7,7 @@ module Rack
|
||||||
module StoreProxy
|
module StoreProxy
|
||||||
class RedisCacheStoreProxy < SimpleDelegator
|
class RedisCacheStoreProxy < SimpleDelegator
|
||||||
def self.handle?(store)
|
def self.handle?(store)
|
||||||
defined?(::Redis) && defined?(::ActiveSupport::Cache::RedisCacheStore) && store.is_a?(::ActiveSupport::Cache::RedisCacheStore)
|
store.class.name == "ActiveSupport::Cache::RedisCacheStore"
|
||||||
end
|
end
|
||||||
|
|
||||||
def increment(name, amount = 1, options = {})
|
def increment(name, amount = 1, options = {})
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require_relative "../../spec_helper"
|
require_relative "../../spec_helper"
|
||||||
|
|
||||||
if defined?(::ConnectionPool) && defined?(::Redis) && defined?(::ActiveSupport::Cache::RedisCacheStore)
|
if defined?(::ConnectionPool) && defined?(::Redis) && Gem::Version.new(::Redis::VERSION) >= Gem::Version.new("4") && defined?(::ActiveSupport::Cache::RedisCacheStore)
|
||||||
require_relative "../../support/cache_store_helper"
|
require_relative "../../support/cache_store_helper"
|
||||||
require "timecop"
|
require "timecop"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require_relative "../../spec_helper"
|
require_relative "../../spec_helper"
|
||||||
|
|
||||||
if defined?(::Redis) && defined?(::ActiveSupport::Cache::RedisCacheStore)
|
if defined?(::Redis) && Gem::Version.new(::Redis::VERSION) >= Gem::Version.new("4") && defined?(::ActiveSupport::Cache::RedisCacheStore)
|
||||||
require_relative "../../support/cache_store_helper"
|
require_relative "../../support/cache_store_helper"
|
||||||
require "timecop"
|
require "timecop"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue