From 3caee5c3ca6e91ff3670f7a62f858229a3c36772 Mon Sep 17 00:00:00 2001 From: Alexey Vasiliev Date: Wed, 20 Jun 2018 22:11:46 +0300 Subject: [PATCH] Fix usage of RedisCacheStore for rails 5.2.0 --- lib/rack/attack/store_proxy/redis_cache_store_proxy.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/rack/attack/store_proxy/redis_cache_store_proxy.rb b/lib/rack/attack/store_proxy/redis_cache_store_proxy.rb index 8bb3f46..dcf085f 100644 --- a/lib/rack/attack/store_proxy/redis_cache_store_proxy.rb +++ b/lib/rack/attack/store_proxy/redis_cache_store_proxy.rb @@ -10,11 +10,13 @@ module Rack def increment(name, amount, options = {}) # Redis doesn't check expiration on the INCRBY command. See https://redis.io/commands/expire - count = redis.pipelined do - redis.incrby(name, amount) - redis.expire(name, options[:expires_in]) if options[:expires_in] + redis.with do |r| + count = r.pipelined do + r.incrby(name, amount) + r.expire(name, options[:expires_in]) if options[:expires_in] + end + count.first end - count.first end def read(name, options = {})