Permalink
Browse files

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
  • Loading branch information...
jeremy committed Feb 1, 2008
1 parent e59de60 commit 601222f294e4665d90914229025cf699ae0fb85a
Showing with 5 additions and 2 deletions.
  1. +5 −2 activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -20,9 +20,12 @@ def read(key, options = nil)
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

0 comments on commit 601222f

Please sign in to comment.