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

Tidy and speed up ActiveSupport::Cache::Store#read_multi_entries

This commit is contained in:
Vinicius Stock 2019-10-11 13:58:24 -04:00 committed by George Claghorn
parent 9d9c749a72
commit 77a416c84f

View file

@ -583,23 +583,20 @@ module ActiveSupport
# Reads multiple entries from the cache implementation. Subclasses MAY # Reads multiple entries from the cache implementation. Subclasses MAY
# implement this method. # implement this method.
def read_multi_entries(names, **options) def read_multi_entries(names, **options)
results = {} names.each_with_object({}) do |name, results|
names.each do |name| key = normalize_key(name, options)
key = normalize_key(name, options) entry = read_entry(key, **options)
version = normalize_version(name, options)
entry = read_entry(key, **options)
if entry next unless entry
if entry.expired?
delete_entry(key, **options) version = normalize_version(name, options)
elsif entry.mismatched?(version)
# Skip mismatched versions if entry.expired?
else delete_entry(key, **options)
results[name] = entry.value elsif !entry.mismatched?(version)
end results[name] = entry.value
end end
end end
results
end end
# Writes multiple entries to the cache implementation. Subclasses MAY # Writes multiple entries to the cache implementation. Subclasses MAY