aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache/mem_cache_store.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-09-20 12:07:21 -0300
committerJosé Valim <jose.valim@gmail.com>2009-09-20 12:07:21 -0300
commit4215e9ab936efca915ca998273d2fc0c46bb59b8 (patch)
treecfb67f70ce1ec8f95ea91c2b548666a87cea58f5 /activesupport/lib/active_support/cache/mem_cache_store.rb
parent09f798ba18029363378d80b19f9f88a055c44bb2 (diff)
downloadrails-4215e9ab936efca915ca998273d2fc0c46bb59b8.tar.gz
rails-4215e9ab936efca915ca998273d2fc0c46bb59b8.tar.bz2
rails-4215e9ab936efca915ca998273d2fc0c46bb59b8.zip
Instrumenting cache stores.
Diffstat (limited to 'activesupport/lib/active_support/cache/mem_cache_store.rb')
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb31
1 files changed, 18 insertions, 13 deletions
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index 7c97b05261..ea38baa9ad 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -54,8 +54,9 @@ module ActiveSupport
end
def read(key, options = nil) # :nodoc:
- super
- @data.get(key, raw?(options))
+ super do
+ @data.get(key, raw?(options))
+ end
rescue MemCache::MemCacheError => e
logger.error("MemCacheError (#{e}): #{e.message}")
nil
@@ -69,22 +70,24 @@ module ActiveSupport
# - <tt>:expires_in</tt> - the number of seconds that this value may stay in
# the cache. See ActiveSupport::Cache::Store#write for an example.
def write(key, value, options = nil)
- super
- method = options && options[:unless_exist] ? :add : :set
- # memcache-client will break the connection if you send it an integer
- # in raw mode, so we convert it to a string to be sure it continues working.
- value = value.to_s if raw?(options)
- response = @data.send(method, key, value, expires_in(options), raw?(options))
- response == Response::STORED
+ super do
+ method = options && options[:unless_exist] ? :add : :set
+ # memcache-client will break the connection if you send it an integer
+ # in raw mode, so we convert it to a string to be sure it continues working.
+ value = value.to_s if raw?(options)
+ response = @data.send(method, key, value, expires_in(options), raw?(options))
+ response == Response::STORED
+ end
rescue MemCache::MemCacheError => e
logger.error("MemCacheError (#{e}): #{e.message}")
false
end
def delete(key, options = nil) # :nodoc:
- super
- response = @data.delete(key, expires_in(options))
- response == Response::DELETED
+ super do
+ response = @data.delete(key, expires_in(options))
+ response == Response::DELETED
+ end
rescue MemCache::MemCacheError => e
logger.error("MemCacheError (#{e}): #{e.message}")
false
@@ -94,7 +97,9 @@ module ActiveSupport
# Doesn't call super, cause exist? in memcache is in fact a read
# But who cares? Reading is very fast anyway
# Local cache is checked first, if it doesn't know then memcache itself is read from
- !read(key, options).nil?
+ super do
+ !read(key, options).nil?
+ end
end
def increment(key, amount = 1) # :nodoc: