aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-11-05 19:21:13 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-11-05 19:21:13 -0700
commitcb67c819338d75c07a591dc23759747c740a5088 (patch)
treeec86334cdbe470a29d35e6e7616994def02502d5 /activesupport/lib/active_support/cache
parent9b663e2679cfdaa2da9bfed0bd4d601309072c22 (diff)
parentb9fb0f262371a668865d0987585933add7085670 (diff)
downloadrails-cb67c819338d75c07a591dc23759747c740a5088.tar.gz
rails-cb67c819338d75c07a591dc23759747c740a5088.tar.bz2
rails-cb67c819338d75c07a591dc23759747c740a5088.zip
Merge pull request #22194 from grosser/grosser/read-nil
cache nil replies from backend cache so misses are fast too
Diffstat (limited to 'activesupport/lib/active_support/cache')
-rw-r--r--activesupport/lib/active_support/cache/strategy/local_cache.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/cache/strategy/local_cache.rb b/activesupport/lib/active_support/cache/strategy/local_cache.rb
index fe5bc82c30..e1da2be2d4 100644
--- a/activesupport/lib/active_support/cache/strategy/local_cache.rb
+++ b/activesupport/lib/active_support/cache/strategy/local_cache.rb
@@ -48,6 +48,10 @@ module ActiveSupport
@data.clear
end
+ def fetch(*args, &block)
+ @data.fetch(*args, &block)
+ end
+
def read_entry(key, options)
@data[key]
end
@@ -99,12 +103,11 @@ module ActiveSupport
protected
def read_entry(key, options) # :nodoc:
if local_cache
- entry = local_cache.read_entry(key, options)
- unless entry
+ local_cache.fetch(key) do
entry = super
local_cache.write_entry(key, entry, options)
+ entry
end
- entry
else
super
end