aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache/strategy/local_cache.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/cache/strategy/local_cache.rb')
-rw-r--r--activesupport/lib/active_support/cache/strategy/local_cache.rb13
1 files changed, 8 insertions, 5 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..4e2d3e9875 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
@@ -98,13 +102,12 @@ module ActiveSupport
protected
def read_entry(key, options) # :nodoc:
- if local_cache
- entry = local_cache.read_entry(key, options)
- unless entry
+ if cache = local_cache
+ cache.fetch(key) do
entry = super
- local_cache.write_entry(key, entry, options)
+ cache.write_entry(key, entry, options)
+ entry
end
- entry
else
super
end