Module: CacheStoreApi::CommonMethods
- Included in:
- CacheStoreApi
- Defined in:
- lib/cache-store-api.rb
Instance Method Summary collapse
Instance Method Details
#data ⇒ Object
21 22 23 |
# File 'lib/cache-store-api.rb', line 21 def data cache.instance_variable_get(:@data) end |
#expire(key) ⇒ Object
17 18 19 |
# File 'lib/cache-store-api.rb', line 17 def expire(key) cache.delete(key) end |
#lazy_cache(key, expiration = 3600) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/cache-store-api.rb', line 3 def lazy_cache(key, expiration=3600) if block_given? if cache.exist?(key) cache.read(key) else output = yield cache.write(key, output, :expires_in => expiration) output end else cache.read(key) end end |