Update with globally keyed fragments

This commit is contained in:
Aditya
2008-11-23 15:17:03 -05:00
parent f3ac3fafbc
commit d67adf1e33

View File

@@ -176,7 +176,25 @@ and you can expire it using the `expire_fragment` method, like so:
[source, ruby]
-----------------------------------------------------
expire_fragment(:controller => 'producst', :action => 'recent', :action_suffix => 'all_products)
expire_fragment(:controller => 'products', :action => 'recent', :action_suffix => 'all_products)
-----------------------------------------------------
If you don't want the cache block to bind to the action that called it, You can
also use globally keyed fragments by calling the cache method with a key, like
so:
[source, ruby]
-----------------------------------------------------
<% cache(:key => ['all_available_products', @latest_product.created_at].join(':')) do %>
All available products:
-----------------------------------------------------
This fragment is then available to all actions in the ProductsController using
the key and can be expired the same way:
[source, ruby]
-----------------------------------------------------
expire_fragment(:key => ['all_available_products', @latest_product.created_at].join(':'))
-----------------------------------------------------
[More: more examples? description of fragment keys and expiration, etc? pagination?]