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
# implement this method.
def read_multi_entries(names, **options)
results = {}
names.each do |name|
key = normalize_key(name, options)
version = normalize_version(name, options)
entry = read_entry(key, **options)
names.each_with_object({}) do |name, results|
key = normalize_key(name, options)
entry = read_entry(key, **options)
if entry
if entry.expired?
delete_entry(key, **options)
elsif entry.mismatched?(version)
# Skip mismatched versions
else
results[name] = entry.value
end
next unless entry
version = normalize_version(name, options)
if entry.expired?
delete_entry(key, **options)
elsif !entry.mismatched?(version)
results[name] = entry.value
end
end
results
end
# Writes multiple entries to the cache implementation. Subclasses MAY