Method: Ramaze::Cache#fetch

Defined in:
lib/ramaze/cache.rb

#fetch(key, default = nil) ⇒ Object Also known as: get

Gets the value of the given key, or default if not found.



85
86
87
88
89
90
# File 'lib/ramaze/cache.rb', line 85

def fetch(key, default = nil)
  return default unless entry = @cache["#{@cache_name}:#{key}"]
  return entry[:value] if entry[:expires].nil? || entry[:expires] > Time.now
  @cache.delete("#{@cache_name}:#{key}")
  default
end