class WithTimedCache::Caches
Public Class Methods
cache_class(format = "")
click to toggle source
# File lib/with_timed_cache/caches.rb, line 27 def cache_class(format = "") format = format.to_s.upcase begin # Ruby Version 1.9 and earlier will choke on this line Object.const_get("WithTimedCache::#{format}Cache") rescue raise WithTimedCache::InvalidCacheFormatException end end
create(key, opts = {})
click to toggle source
# File lib/with_timed_cache/caches.rb, line 23 def create(key, opts = {}) cache_class(opts[:format]).new(key, opts) end
find(key)
click to toggle source
# File lib/with_timed_cache/caches.rb, line 19 def find(key) @caches.select { |c| c.key == key }.first end
find_or_create(key, opts = {})
click to toggle source
# File lib/with_timed_cache/caches.rb, line 13 def find_or_create(key, opts = {}) cache = find(key) || create(key, opts) @caches << cache cache end