From 5394be374dd20c34ddf128cfd04d6b80096a4acb Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Sat, 30 Jun 2018 12:52:29 +0800 Subject: Fix Cache :redis_store increment/decrement ttl check and add more tests. --- activesupport/lib/active_support/cache/redis_cache_store.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/cache') diff --git a/activesupport/lib/active_support/cache/redis_cache_store.rb b/activesupport/lib/active_support/cache/redis_cache_store.rb index 95f8f639e8..a05718b663 100644 --- a/activesupport/lib/active_support/cache/redis_cache_store.rb +++ b/activesupport/lib/active_support/cache/redis_cache_store.rb @@ -264,7 +264,7 @@ module ActiveSupport failsafe :increment do redis.with do |c| val = c.incrby key, amount - if expires_in > 0 && c.ttl(key) == -2 + if expires_in > 0 && c.ttl(key) < 0 c.expire key, expires_in end val @@ -290,7 +290,7 @@ module ActiveSupport failsafe :decrement do redis.with do |c| val = c.decrby key, amount - if expires_in > 0 && c.ttl(key) == -2 + if expires_in > 0 && c.ttl(key) < 0 c.expire key, expires_in end val -- cgit v1.2.3