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:
parent
bfb54aefa6
commit
9f07b1edcd
1 changed files with 5 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue