mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Merge pull request #445 from fatkodima/redis-proxy-increment
Fix rescuing errors in RedisProxy#increment
This commit is contained in:
commit
9cf227a32e
2 changed files with 14 additions and 6 deletions
|
|
@ -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 = {})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue