aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache
diff options
context:
space:
mode:
authorIgnatius Reza <lyoneil.de.sire@gmail.com>2017-08-18 09:32:19 +0900
committerIgnatius Reza <lyoneil.de.sire@gmail.com>2017-12-29 10:12:32 +0900
commit62023884f76c108127c8966f4d67bb717338dd66 (patch)
treef06fff52fc7f16c3c2c4371d43a55758ee7bdba7 /activesupport/lib/active_support/cache
parentdab7d401e8dd6192e36787f7b5b574d30b368388 (diff)
downloadrails-62023884f76c108127c8966f4d67bb717338dd66.tar.gz
rails-62023884f76c108127c8966f4d67bb717338dd66.tar.bz2
rails-62023884f76c108127c8966f4d67bb717338dd66.zip
add instrumentation for read_multi
currently it's not possible to know what the hit rates are from read_multi
Diffstat (limited to 'activesupport/lib/active_support/cache')
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb40
1 files changed, 18 insertions, 22 deletions
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index df8bc8e43e..00a3670d64 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -91,28 +91,6 @@ module ActiveSupport
end
end
- # Reads multiple values from the cache using a single call to the
- # servers for all keys. Options can be passed in the last argument.
- def read_multi(*names)
- options = names.extract_options!
- options = merged_options(options)
-
- keys_to_names = Hash[names.map { |name| [normalize_key(name, options), name] }]
-
- raw_values = @data.get_multi(keys_to_names.keys)
- values = {}
-
- raw_values.each do |key, value|
- entry = deserialize_entry(value)
-
- unless entry.expired? || entry.mismatched?(normalize_version(keys_to_names[key], options))
- values[keys_to_names[key]] = entry.value
- end
- end
-
- values
- end
-
# Increment a cached value. This method uses the memcached incr atomic
# operator and can only be used on values written with the :raw option.
# Calling it on a value not stored with :raw will initialize that value
@@ -170,6 +148,24 @@ module ActiveSupport
end
end
+ # Reads multiple entries from the cache implementation.
+ def read_multi_entries(names, options)
+ keys_to_names = Hash[names.map { |name| [normalize_key(name, options), name] }]
+
+ raw_values = @data.get_multi(keys_to_names.keys)
+ values = {}
+
+ raw_values.each do |key, value|
+ entry = deserialize_entry(value)
+
+ unless entry.expired? || entry.mismatched?(normalize_version(keys_to_names[key], options))
+ values[keys_to_names[key]] = entry.value
+ end
+ end
+
+ values
+ end
+
# Delete an entry from the cache.
def delete_entry(key, options)
rescue_error_with(false) { @data.delete(key) }