This gem adds the cache_key
functionality to ActiveRecord scopes.
This is useful when caching a page that contains multiple records. It is now possible to cache the entire page based on a scope. If any record in the scope changes, the entire cache will be busted.
This should likely be used in a Russian Doll Caching scenario.
NOTE: This currently only works with Postgresql. Adding support for MySQL should be trivial.
Add this line to your application's Gemfile:
gem 'scope_cache_key'
Example:
<%
scope = Article.page(1) # This should probably be done in your controller!
cache scope do
# logic to render and cache each article here
end
%>
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request