vendor/rails/activesupport/lib/active_support/cache.rb in radiant-0.8.0 vs vendor/rails/activesupport/lib/active_support/cache.rb in radiant-0.8.1

- old
+ new

@@ -89,15 +89,20 @@ # cache.write("city", "Duckburgh") # cache.read("city") # => "Duckburgh" 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. # # If there is no such data in the cache (a cache miss occurred), then # then nil will be returned. However, if a block has been passed, then @@ -218,11 +223,19 @@ nil end 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 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 end