diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2015-11-07 18:17:08 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2015-11-07 18:17:08 +0100 |
commit | 5336a6333cfd5eba8bcbe4e28a1a875b786146f4 (patch) | |
tree | bcfb189775a0db1da205e39974b4afc20c5d3b94 /activesupport/lib/active_support | |
parent | 24bddfc542cf218e395029db3ece4502ae79eb3d (diff) | |
parent | e401a6bb251d382901d0e4e80b09545b29b16a89 (diff) | |
download | rails-5336a6333cfd5eba8bcbe4e28a1a875b786146f4.tar.gz rails-5336a6333cfd5eba8bcbe4e28a1a875b786146f4.tar.bz2 rails-5336a6333cfd5eba8bcbe4e28a1a875b786146f4.zip |
Merge pull request #22197 from grosser/grosser/fetch
do not override fetch on local cache
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/cache/strategy/local_cache.rb | 14 |
1 files changed, 5 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 4e2d3e9875..d521061004 100644 --- a/activesupport/lib/active_support/cache/strategy/local_cache.rb +++ b/activesupport/lib/active_support/cache/strategy/local_cache.rb @@ -48,10 +48,6 @@ module ActiveSupport @data.clear end - def fetch(*args, &block) - @data.fetch(*args, &block) - end - def read_entry(key, options) @data[key] end @@ -64,6 +60,10 @@ module ActiveSupport def delete_entry(key, options) !!@data.delete(key) end + + def fetch_entry(key, options = nil) # :nodoc: + @data.fetch(key) { @data[key] = yield } + end end # Use a local cache for the duration of block. @@ -103,11 +103,7 @@ module ActiveSupport protected def read_entry(key, options) # :nodoc: if cache = local_cache - cache.fetch(key) do - entry = super - cache.write_entry(key, entry, options) - entry - end + cache.fetch_entry(key) { super } else super end |