aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorTobias Lütke <tobi@jadedpixel.com>2008-04-29 14:57:21 -0400
committerTobias Lütke <tobi@jadedpixel.com>2008-04-29 14:57:21 -0400
commit9f07b1edcd2955dc7af166c422309da55372a92c (patch)
tree08a62e7756adc111fed7998f7a35524790ff8753 /activesupport/lib
parentbfb54aefa6bbff194eeb81b8e797ddde24aaae95 (diff)
downloadrails-9f07b1edcd2955dc7af166c422309da55372a92c.tar.gz
rails-9f07b1edcd2955dc7af166c422309da55372a92c.tar.bz2
rails-9f07b1edcd2955dc7af166c422309da55372a92c.zip
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.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index 9b787702b2..ad220a9c2c 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -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
@@ -54,8 +53,8 @@ module ActiveSupport
def delete_matched(matcher, options = nil)
super
raise "Not supported by Memcache"
- end
-
+ end
+
def clear
@data.flush_all
end