Fix usage of RedisCacheStore for rails 5.2.0

This commit is contained in:
Alexey Vasiliev 2018-06-20 22:11:46 +03:00 committed by Gonzalo Rodriguez
parent e830804586
commit 3caee5c3ca
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1

View file

@ -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 = {})