diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-01-07 13:49:02 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-07 13:49:02 -0500 |
commit | cd16413ef3280a50c1b13b1ed7be1a907fad88d1 (patch) | |
tree | ddea7224f0ee93bc8229b395fc57d33b5ad80eb6 /activesupport/lib | |
parent | 9cfcc067e626f0f1e220cc00a9f96622a936350d (diff) | |
parent | 94ecf95674f81c5590c8f08549208907b81e3bf8 (diff) | |
download | rails-cd16413ef3280a50c1b13b1ed7be1a907fad88d1.tar.gz rails-cd16413ef3280a50c1b13b1ed7be1a907fad88d1.tar.bz2 rails-cd16413ef3280a50c1b13b1ed7be1a907fad88d1.zip |
Merge pull request #34700 from gmcgibbon/fetch_multi_key_order
Preserve key order of #fetch_multi
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index e8518645d9..30a69c550b 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -438,18 +438,18 @@ module ActiveSupport options = merged_options(options) instrument :read_multi, names, options do |payload| - read_multi_entries(names, options).tap do |results| - payload[:hits] = results.keys - payload[:super_operation] = :fetch_multi + reads = read_multi_entries(names, options) + writes = {} + ordered = names.each_with_object({}) do |name, hash| + hash[name] = reads.fetch(name) { writes[name] = yield(name) } + end - writes = {} + payload[:hits] = reads.keys + payload[:super_operation] = :fetch_multi - (names - results.keys).each do |name| - results[name] = writes[name] = yield(name) - end + write_multi(writes, options) - write_multi writes, options - end + ordered end end |