diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2015-12-19 08:00:20 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2015-12-19 08:00:20 +0100 |
commit | 5b922d2a36a81c1b07818db1b5bbb2e2fc9931a7 (patch) | |
tree | 2f5577f835818ffd68d2ea25fa3b31178ba5cbb3 /activesupport/lib | |
parent | fb77aa33f79bbabcc9fbe4981e9828cc40aa2805 (diff) | |
parent | d27d6c84fd1ca3e38eb40fe3a08e7a9219941aa5 (diff) | |
download | rails-5b922d2a36a81c1b07818db1b5bbb2e2fc9931a7.tar.gz rails-5b922d2a36a81c1b07818db1b5bbb2e2fc9931a7.tar.bz2 rails-5b922d2a36a81c1b07818db1b5bbb2e2fc9931a7.zip |
Merge pull request #22479 from RobinClowers/fix-cache-notification-order
Fix cache fetch miss notification order
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 16 |
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) |