From 601222f294e4665d90914229025cf699ae0fb85a Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 1 Feb 2008 07:07:56 +0000 Subject: MemCacheStore#write uses add by default and set if :force => true git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8765 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/cache/mem_cache_store.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/cache') diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb index 5f38c4f1ce..12b450ed86 100644 --- a/activesupport/lib/active_support/cache/mem_cache_store.rb +++ b/activesupport/lib/active_support/cache/mem_cache_store.rb @@ -20,9 +20,12 @@ module ActiveSupport nil end - def write(key, value, options = nil) + # Set key = value if key isn't already set. Pass :force => true + # to unconditionally set key = value. + def write(key, value, options = {}) super - @data.set(key, value, expires_in(options), raw?(options)) + method = options[:force] ? :set : :add + @data.send(method, key, value, expires_in(options), raw?(options)) rescue MemCache::MemCacheError => e logger.error("MemCacheError (#{e}): #{e.message}") nil -- cgit v1.2.3