aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorMike Evans <mike@urlgonomics.com>2012-10-11 15:46:30 -0400
committerMike Evans <mike@urlgonomics.com>2012-10-11 15:46:30 -0400
commit13d8777b63f93426f6a1101f066cc3cf218109d3 (patch)
treec5c3aa82a69fe8c774029e7d75596c48187f8576 /activesupport
parent888a7a5bdc10bf5e2aceaad1cd40979a2388e4c0 (diff)
downloadrails-13d8777b63f93426f6a1101f066cc3cf218109d3.tar.gz
rails-13d8777b63f93426f6a1101f066cc3cf218109d3.tar.bz2
rails-13d8777b63f93426f6a1101f066cc3cf218109d3.zip
Padding expires_in by 5 minutes on dalli key write to facilitate :race_condition_ttl working correctly.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index 5aa78cc9f3..17450fe4d0 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -132,6 +132,10 @@ module ActiveSupport
method = options && options[:unless_exist] ? :add : :set
value = options[:raw] ? entry.value.to_s : entry
expires_in = options[:expires_in].to_i
+ if expires_in > 0 && !options[:raw]
+ # Set the memcache expire a few minutes in the future to support race condition ttls on read
+ expires_in += 5.minutes
+ end
@data.send(method, escape_key(key), value, expires_in, options)
rescue Dalli::DalliError => e
logger.error("DalliError (#{e}): #{e.message}") if logger