Module | Merb::Cache::ControllerInstanceMethods |
In: |
lib/merb-cache/cache-action.rb
lib/merb-cache/cache-fragment.rb lib/merb-cache/cache-page.rb lib/merb-cache/merb-cache.rb |
DEFAULT_PAGE_EXTENSION | = | 'html' | Mixed in Merb::Controller. Provides methods related to page caching |
In your view: <%- cache("my_key") do -%> <%= partial :test, :collection => @test %> <%- end -%>
Fetch data from cache
options<String,Hash>: | The options that will be passed to key_for |
data<Object,NilClass>: | nil is returned if the cache entry is not found |
if cache_data = cache_get("my_key") @var1, @var2 = *cache_data else @var1 = MyModel.big_query1 @var2 = MyModel.big_query2 cache_set("my_key", nil, [@var1, @var2]) end
Store data to cache
options<String,Hash>: | The options that will be passed to key_for |
object<Object>: | The object(s) to put in cache |
from_now<~minutes>: | The number of minutes (from now) the cache should persist |
data<Object,NilClass>: | nil is returned if the cache entry is not found |
if cache_data = cache_get("my_key") @var1, @var2 = *cache_data else @var1 = MyModel.big_query1 @var2 = MyModel.big_query2 cache_set("my_key", nil, [@var1, @var2]) end
Expires the entry identified by the key computed after the parameters
options<String,Hash>: | The options that will be passed to key_for |
expire("my_key") expire(:key => "my_", :match => true) expire(:key => "my_key", :params => [session[:me], params[:ref]])
Expires the action identified by the key computed after the parameters
options<String,Hash>: | The options that will be passed to expire_key_for |
expire_action(:action => 'show', :controller => 'news') expire_action(:action => 'show', :match => true)
Expires the page identified by the key computed after the parameters
options<String,Hash>: | The options that will be passed to expire_key_for |
expire_page(:action => 'show', :controller => 'news') expire_page(:action => 'show', :match => true) expire_page(:action => 'show', :extension => 'js')