1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

By default rails will update keys in memcached when using Rails.cache.write. Use :unless_exist => true flag to prevent existing keys from being overwritten.

This commit is contained in:
Tobias Lütke 2008-04-29 14:57:21 -04:00
parent bfb54aefa6
commit 9f07b1edcd

View file

@ -29,12 +29,11 @@ module ActiveSupport
nil
end
# Set key = value if key isn't already set. Pass :force => true
# to unconditionally set key = value. Returns a boolean indicating
# whether the key was set.
# Set key = value. Pass :unless_exist => true if you don't
# want to update the cache if the key is already set.
def write(key, value, options = nil)
super
method = options && options[:force] ? :set : :add
method = options && options[:unless_exist] ? :add : :set
response = @data.send(method, key, value, expires_in(options), raw?(options))
response == Response::STORED
rescue MemCache::MemCacheError => e