module WithTimedCache
Constants
- VERSION
Public Instance Methods
with_timed_cache(key, opts = {}) { || ... }
click to toggle source
# File lib/with_timed_cache.rb, line 5 def with_timed_cache(key, opts = {}) cache = Caches.find_or_create(key, opts) if cache.exists? && !cache.stale? data = cache.read else begin data = yield cache.write(data) rescue Exception => e data = cache.read rescue nil end end data end