Fix rescuing errors in RedisProxy#increment

This commit is contained in:
fatkodima 2019-10-14 23:16:52 +03:00 committed by Gonzalo Rodriguez
parent 3654293085
commit 6cca2467d2
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1
2 changed files with 14 additions and 6 deletions

View file

@ -31,16 +31,12 @@ module Rack
end
def increment(key, amount, options = {})
count = nil
rescuing do
pipelined do
count = incrby(key, amount)
incrby(key, amount)
expire(key, options[:expires_in]) if options[:expires_in]
end
end.first
end
count.value if count
end
def delete(key, _options = {})

View file

@ -45,3 +45,15 @@ if defined?(::Dalli)
end
end
end
if defined?(Redis)
describe 'when Redis is offline' do
include OfflineExamples
before do
@cache = Rack::Attack::Cache.new
# Use presumably unused port for Redis client
@cache.store = Redis.new(host: '127.0.0.1', port: 3333)
end
end
end