Class: Rabl::CacheEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/rabl/cache_engine.rb

Instance Method Summary collapse

Instance Method Details

#fetch(key, cache_options, &block) ⇒ Object

Fetch given a key and options and a fallback block attempts to find the key in the cache and stores the block result in there if no key is found.

cache = Rabl::CacheEngine.new; cache.fetch(“some_key”) { “fallback data” }



16
17
18
19
20
21
22
# File 'lib/rabl/cache_engine.rb', line 16

def fetch(key, cache_options, &block)
  if defined?(Rails)
    Rails.cache.fetch(key, cache_options, &block)
  else
    yield
  end
end