aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorRobin Clowers <robin.clowers@gmail.com>2015-12-02 21:10:08 -0800
committerRobin Clowers <robin.clowers@gmail.com>2015-12-02 21:27:29 -0800
commitd27d6c84fd1ca3e38eb40fe3a08e7a9219941aa5 (patch)
treeee32027009a3902f89218d01760d302899e9b51e /activesupport/lib
parent215f86c3483cf300b2ccd6d5d8b97f9c9bf547f5 (diff)
downloadrails-d27d6c84fd1ca3e38eb40fe3a08e7a9219941aa5.tar.gz
rails-d27d6c84fd1ca3e38eb40fe3a08e7a9219941aa5.tar.bz2
rails-d27d6c84fd1ca3e38eb40fe3a08e7a9219941aa5.zip
Fix cache fetch miss notification order
Fixes https://github.com/rails/rails/issues/22477. When I improved the caching instrumentation in edd33c08d98723ae9bb89cf7f019277117ed6414, I inadvertently changed the order of AS notifications when there is a cache miss.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/cache.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index 5011014e96..8272d3395c 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -278,18 +278,18 @@ module ActiveSupport
options = merged_options(options)
key = normalize_key(name, options)
+ entry = nil
instrument(:read, name, options) do |payload|
cached_entry = read_entry(key, options) unless options[:force]
- payload[:super_operation] = :fetch if payload
entry = handle_expired_entry(cached_entry, key, options)
+ payload[:super_operation] = :fetch if payload
+ payload[:hit] = !!entry if payload
+ end
- if entry
- payload[:hit] = true if payload
- get_entry_value(entry, name, options)
- else
- payload[:hit] = false if payload
- save_block_result_to_cache(name, options) { |_name| yield _name }
- end
+ if entry
+ get_entry_value(entry, name, options)
+ else
+ save_block_result_to_cache(name, options) { |_name| yield _name }
end
else
read(name, options)