Method: FastCache::Cache#fetch
- Defined in:
- lib/fast_cache/cache.rb
#fetch(key) { ... } ⇒ Object
Retrieves a value from the cache, if available and not expired, or yields to a block that calculates the value to be stored in the cache.
51 52 53 54 55 56 57 58 |
# File 'lib/fast_cache/cache.rb', line 51 def fetch(key) found, value = get(key) if found value else store(key, yield) end end |