aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache
diff options
context:
space:
mode:
authorJason Lee <huacnlee@gmail.com>2018-06-30 12:52:29 +0800
committerJason Lee <huacnlee@gmail.com>2018-06-30 12:52:29 +0800
commit5394be374dd20c34ddf128cfd04d6b80096a4acb (patch)
treee31bb735e69f2688e581d9da440a1c3e2bda801c /activesupport/lib/active_support/cache
parenta9692941600c34afbc8d60d15cb5f179d30f67e5 (diff)
downloadrails-5394be374dd20c34ddf128cfd04d6b80096a4acb.tar.gz
rails-5394be374dd20c34ddf128cfd04d6b80096a4acb.tar.bz2
rails-5394be374dd20c34ddf128cfd04d6b80096a4acb.zip
Fix Cache :redis_store increment/decrement ttl check and add more tests.
Diffstat (limited to 'activesupport/lib/active_support/cache')
-rw-r--r--activesupport/lib/active_support/cache/redis_cache_store.rb4
1 files changed, 2 insertions, 2 deletions
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