From 8a537b8e54d7446c2a90d0daacb8d69795602e58 Mon Sep 17 00:00:00 2001 From: Elad Meidar Date: Fri, 25 Sep 2009 10:52:11 -0400 Subject: [PATCH] LH2969 - fixed existing patch to apply on Master --- activesupport/lib/active_support/cache.rb | 5 ----- .../lib/active_support/cache/mem_cache_store.rb | 10 ++++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 25f9555..4c740ad 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -230,11 +230,6 @@ module ActiveSupport end private - def expires_in(options) - 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 instrument(operation, key, options, &block) payload = { :key => key } diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb index 516af99..33a81ca 100644 --- a/activesupport/lib/active_support/cache/mem_cache_store.rb +++ b/activesupport/lib/active_support/cache/mem_cache_store.rb @@ -15,6 +15,9 @@ module ActiveSupport # - Time-based expiry support. See #write and the :expires_in option. # - Per-request in memory cache for all communication with the MemCache server(s). class MemCacheStore < Store + + cattr_accessor :default_expires_in + module Response # :nodoc: STORED = "STORED\r\n" NOT_STORED = "NOT_STORED\r\n" @@ -27,6 +30,7 @@ module ActiveSupport addresses = addresses.flatten options = addresses.extract_options! addresses = ["localhost"] if addresses.empty? + self.default_expires_in = options[:expires_in] MemCache.new(addresses, options) end @@ -138,6 +142,12 @@ module ActiveSupport def raw?(options) options && options[:raw] end + + def expires_in(options) + expires_in = options && options[:expires_in] || default_expires_in + raise ":expires_in must be a number" if expires_in && !expires_in.is_a?(Numeric) + expires_in || 0 + end end end end -- 1.6.0.2