aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache.rb
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-01 16:56:43 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-01 16:56:43 -0700
commitee7d4c47e7abf1e5ec8f4d4a1e937cdee5bb8d9c (patch)
treede8bce11c912a72a20cf67709aaa010efd6bc6f8 /activesupport/lib/active_support/cache.rb
parent92bff2ebf122252cf3ff64160bdfa9891fcff3f4 (diff)
downloadrails-ee7d4c47e7abf1e5ec8f4d4a1e937cdee5bb8d9c.tar.gz
rails-ee7d4c47e7abf1e5ec8f4d4a1e937cdee5bb8d9c.tar.bz2
rails-ee7d4c47e7abf1e5ec8f4d4a1e937cdee5bb8d9c.zip
Fixes bug where Memcached connections get corrupted when an invalid expire is passed in [#2854 state:resolved]
Diffstat (limited to 'activesupport/lib/active_support/cache.rb')
-rw-r--r--activesupport/lib/active_support/cache.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index 3c422e0252..448db538ab 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -99,11 +99,16 @@ module ActiveSupport
class Store
cattr_accessor :logger
+ attr_reader :silence, :logger_off
+
def silence!
@silence = true
self
end
+ alias silence? silence
+ alias logger_off? logger_off
+
# 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.
#
@@ -233,11 +238,15 @@ module ActiveSupport
private
def expires_in(options)
- (options && options[:expires_in]) || 0
+ expires_in = options && options[:expires_in]
+
+ raise ":expires_in must be a number" if expires_in && !expires_in.is_a?(Numeric)
+
+ expires_in || 0
end
def log(operation, key, options)
- logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@silence && !@logger_off
+ logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !silence? && !logger_off?
end
end
end