mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Remove support for unmaintained ActiveSupport::Cache::RedisStore (#625)
* remove support for unmaintained ActiveSupport::Cache::RedisStore * ci: removes active_support_redis_store matrix job * test: removes unecessary redis-activesupport require * test: removes dead code * fix typo --------- Co-authored-by: Gonzalo <456459+grzuy@users.noreply.github.com>
This commit is contained in:
parent
c9bd363a69
commit
9a7815c332
9 changed files with 1 additions and 88 deletions
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
|
|
@ -40,7 +40,6 @@ jobs:
|
|||
- active_support_redis_cache_store
|
||||
- active_support_redis_cache_store_pooled
|
||||
- redis_store
|
||||
- active_support_redis_store
|
||||
exclude:
|
||||
- gemfile: rack_1
|
||||
ruby: 3.2.2
|
||||
|
|
|
|||
|
|
@ -80,8 +80,3 @@ end
|
|||
appraise "redis_store" do
|
||||
gem "redis-store", "~> 1.5"
|
||||
end
|
||||
|
||||
appraise "active_support_redis_store" do
|
||||
gem "redis-activesupport", "~> 5.0"
|
||||
gem 'redis-store', '1.9.1' # remove after https://github.com/redis-store/redis-store/issues/358 is resolved
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
# This file was generated by Appraisal
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem "redis-activesupport", "~> 5.0"
|
||||
gem "redis-store", "1.9.1"
|
||||
|
||||
gemspec path: "../"
|
||||
|
|
@ -11,7 +11,6 @@ require 'rack/attack/store_proxy/mem_cache_store_proxy'
|
|||
require 'rack/attack/store_proxy/redis_proxy'
|
||||
require 'rack/attack/store_proxy/redis_store_proxy'
|
||||
require 'rack/attack/store_proxy/redis_cache_store_proxy'
|
||||
require 'rack/attack/store_proxy/active_support_redis_store_proxy'
|
||||
|
||||
require 'rack/attack/railtie' if defined?(::Rails)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rack/attack/base_proxy'
|
||||
|
||||
module Rack
|
||||
class Attack
|
||||
module StoreProxy
|
||||
class ActiveSupportRedisStoreProxy < BaseProxy
|
||||
def self.handle?(store)
|
||||
defined?(::Redis) &&
|
||||
defined?(::ActiveSupport::Cache::RedisStore) &&
|
||||
store.is_a?(::ActiveSupport::Cache::RedisStore)
|
||||
end
|
||||
|
||||
def increment(name, amount = 1, options = {})
|
||||
# #increment ignores options[:expires_in].
|
||||
#
|
||||
# So in order to workaround this we use #write (which sets expiration) to initialize
|
||||
# the counter. After that we continue using the original #increment.
|
||||
if options[:expires_in] && !read(name)
|
||||
write(name, amount, options)
|
||||
|
||||
amount
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def read(name, options = {})
|
||||
super(name, options.merge!(raw: true))
|
||||
end
|
||||
|
||||
def write(name, value, options = {})
|
||||
super(name, value, options.merge!(raw: true))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative "../../spec_helper"
|
||||
|
||||
if defined?(::ActiveSupport::Cache::RedisStore)
|
||||
require_relative "../../support/cache_store_helper"
|
||||
require "timecop"
|
||||
|
||||
describe "ActiveSupport::Cache::RedisStore as a cache backend" do
|
||||
before do
|
||||
Rack::Attack.cache.store = ActiveSupport::Cache::RedisStore.new
|
||||
end
|
||||
|
||||
after do
|
||||
Rack::Attack.cache.store.clear
|
||||
end
|
||||
|
||||
it_works_for_cache_backed_features(fetch_from_store: ->(key) { Rack::Attack.cache.store.read(key) })
|
||||
end
|
||||
end
|
||||
|
|
@ -6,7 +6,7 @@ require_relative "../../support/cache_store_helper"
|
|||
if defined?(::Redis::Store)
|
||||
require "timecop"
|
||||
|
||||
describe "ActiveSupport::Cache::RedisStore as a cache backend" do
|
||||
describe "Redis::Store as a cache backend" do
|
||||
before do
|
||||
Rack::Attack.cache.store = ::Redis::Store.new
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,18 +21,6 @@ OfflineExamples = Minitest::SharedExamples.new do
|
|||
end
|
||||
end
|
||||
|
||||
if defined?(::ActiveSupport::Cache::RedisStore)
|
||||
describe 'when Redis is offline' do
|
||||
include OfflineExamples
|
||||
|
||||
before do
|
||||
@cache = Rack::Attack::Cache.new
|
||||
# Use presumably unused port for Redis client
|
||||
@cache.store = ActiveSupport::Cache::RedisStore.new(host: '127.0.0.1', port: 3333)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(Redis) && defined?(ActiveSupport::Cache::RedisCacheStore) && Redis::VERSION >= '4'
|
||||
describe 'when Redis is offline' do
|
||||
include OfflineExamples
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ end
|
|||
safe_require "connection_pool"
|
||||
safe_require "dalli"
|
||||
safe_require "redis"
|
||||
safe_require "redis-activesupport"
|
||||
safe_require "redis-store"
|
||||
|
||||
class Minitest::Spec
|
||||
|
|
|
|||
Loading…
Reference in a new issue