diff options
author | Michael Grosser <michael@grosser.it> | 2015-11-07 12:27:39 -0800 |
---|---|---|
committer | Michael Grosser <michael@grosser.it> | 2015-11-07 12:27:39 -0800 |
commit | cfc6d8356f71357d6a5e9e978ea246e95bc7bf0f (patch) | |
tree | 24b8eeecbe6a33e62c4f350aed09c9defd370b60 /activesupport | |
parent | 3aa5f2c203f1161a63a1e5be5b5263c339e2653b (diff) | |
download | rails-cfc6d8356f71357d6a5e9e978ea246e95bc7bf0f.tar.gz rails-cfc6d8356f71357d6a5e9e978ea246e95bc7bf0f.tar.bz2 rails-cfc6d8356f71357d6a5e9e978ea246e95bc7bf0f.zip |
fast and consistent return when local_cache does not exist
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/cache/strategy/local_cache.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/cache/strategy/local_cache.rb b/activesupport/lib/active_support/cache/strategy/local_cache.rb index d521061004..fa007aad56 100644 --- a/activesupport/lib/active_support/cache/strategy/local_cache.rb +++ b/activesupport/lib/active_support/cache/strategy/local_cache.rb @@ -79,22 +79,26 @@ module ActiveSupport end def clear(options = nil) # :nodoc: - local_cache.clear(options) if local_cache + return super unless cache = local_cache + cache.clear(options) super end def cleanup(options = nil) # :nodoc: - local_cache.clear(options) if local_cache + return super unless cache = local_cache + cache.clear(options) super end def increment(name, amount = 1, options = nil) # :nodoc: + return super unless local_cache value = bypass_local_cache{super} set_cache_value(value, name, amount, options) value end def decrement(name, amount = 1, options = nil) # :nodoc: + return super unless local_cache value = bypass_local_cache{super} set_cache_value(value, name, amount, options) value @@ -120,13 +124,12 @@ module ActiveSupport end def set_cache_value(value, name, amount, options) # :nodoc: - if local_cache - local_cache.mute do - if value - local_cache.write(name, value, options) - else - local_cache.delete(name, options) - end + cache = local_cache + cache.mute do + if value + cache.write(name, value, options) + else + cache.delete(name, options) end end end |