From b9fb0f262371a668865d0987585933add7085670 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Thu, 5 Nov 2015 17:43:22 -0800 Subject: cache nil replies from backend cache so misses are fast too --- activesupport/lib/active_support/cache/strategy/local_cache.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support/cache/strategy/local_cache.rb') 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 -- cgit v1.2.3