mattallen/cached-partials
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Cached Partials ========= Cached partials allows you to control you cache generation from your models. It's a set and forget method once you have done the initial setup. Partials will be re-rendered every time a model is created/saved/destroyed. Set it up as follows: ./script/install plugin git://github.com/tra/spawn.git ./script/install plugin git://github.com/mattallen/cached-partials.git Set up memcache in environment.rb config.cache_store = :mem_cache_store, ["localhost", {:namespace => "yourapp-"}] in environment.rb (or production.rb) include the constants CACHE_URL = "http://localhost:3000" CACHE_KEY = "some_secrit_key" FORCE_KEY = "force" Make a collection and member folder in the views directory of the models you want to cache. For Members ========== <% cp_cache("model:method:#{record.id}",{:force => params[FORCE_KEY] == "1"}) do %> ## record variable contains your record <% end %> For Collections ========== <% cp_cache("model:method",{:force => params[FORCE_KEY] == "1"}) do %> <% @posts = Post.last_5 %> ## as above, call a named scope or class method to retrieve needed records <% end %>
About
Set and forget Caching for Rails
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published