diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-10-09 15:03:18 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-10-09 15:03:18 +0100 |
commit | 987d501182971c1e6cdf8acb748635d14cf0c341 (patch) | |
tree | d6fb084a26d50230e592e29f02a207460d37c869 /activesupport/lib | |
parent | 16a48a95e3cb0044587df7b0e83b017a94506739 (diff) | |
download | rails-987d501182971c1e6cdf8acb748635d14cf0c341.tar.gz rails-987d501182971c1e6cdf8acb748635d14cf0c341.tar.bz2 rails-987d501182971c1e6cdf8acb748635d14cf0c341.zip |
Mute log info coming from the local_cache strategy
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 7 | ||||
-rw-r--r-- | activesupport/lib/active_support/cache/memory_store.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/cache/strategy/local_cache.rb | 10 |
3 files changed, 14 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 25f9555388..a415686020 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -115,6 +115,13 @@ module ActiveSupport self end + def mute + previous_silence, @silence = defined?(@silence) && @silence, true + yield + ensure + @silence = previous_silence + end + # Fetches data from the cache, using the given key. If there is data in # the cache with the given key, then that data is returned. # diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb index 66ce1bc93a..e6085d97ec 100644 --- a/activesupport/lib/active_support/cache/memory_store.rb +++ b/activesupport/lib/active_support/cache/memory_store.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/object/duplicable' + module ActiveSupport module Cache # A cache store implementation which stores everything into memory in the diff --git a/activesupport/lib/active_support/cache/strategy/local_cache.rb b/activesupport/lib/active_support/cache/strategy/local_cache.rb index 3b5fccc737..5f6fe22416 100644 --- a/activesupport/lib/active_support/cache/strategy/local_cache.rb +++ b/activesupport/lib/active_support/cache/strategy/local_cache.rb @@ -44,7 +44,7 @@ module ActiveSupport nil elsif value.nil? value = super - local_cache.write(key, value || NULL) if local_cache + local_cache.mute { local_cache.write(key, value || NULL) } if local_cache value.duplicable? ? value.dup : value else # forcing the value to be immutable @@ -54,12 +54,12 @@ module ActiveSupport def write(key, value, options = nil) value = value.to_s if respond_to?(:raw?) && raw?(options) - local_cache.write(key, value || NULL) if local_cache + local_cache.mute { local_cache.write(key, value || NULL) } if local_cache super end def delete(key, options = nil) - local_cache.write(key, NULL) if local_cache + local_cache.mute { local_cache.write(key, NULL) } if local_cache super end @@ -76,7 +76,7 @@ module ActiveSupport def increment(key, amount = 1) if value = super - local_cache.write(key, value.to_s) if local_cache + local_cache.mute { local_cache.write(key, value.to_s) } if local_cache value else nil @@ -85,7 +85,7 @@ module ActiveSupport def decrement(key, amount = 1) if value = super - local_cache.write(key, value.to_s) if local_cache + local_cache.mute { local_cache.write(key, value.to_s) } if local_cache value else nil |