aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-02-01 07:07:56 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-02-01 07:07:56 +0000
commit601222f294e4665d90914229025cf699ae0fb85a (patch)
treef6a754c2570d109092b8705e96361a7c96a599c0 /activesupport/lib/active_support/cache
parente59de6046cf01852e1b16e7a6a39de94aefa7e72 (diff)
downloadrails-601222f294e4665d90914229025cf699ae0fb85a.tar.gz
rails-601222f294e4665d90914229025cf699ae0fb85a.tar.bz2
rails-601222f294e4665d90914229025cf699ae0fb85a.zip
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
Diffstat (limited to 'activesupport/lib/active_support/cache')
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb7
1 files changed, 5 insertions, 2 deletions
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