This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Run the following if you haven't already:
gem sources -a http://gems.github.com
Install the gem(s):
sudo gem install ryanb-render-caching
commit 005b47e8727d79efc406b9cf920d80c47241ed6d
tree 78da14c0f909dca49eb78d39a6dd523c1294a659
parent 3c4f256bd5ac3e10ab9ed58784e65b3b874dafd2
tree 78da14c0f909dca49eb78d39a6dd523c1294a659
parent 3c4f256bd5ac3e10ab9ed58784e65b3b874dafd2
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
CHANGELOG | ||
| |
LICENSE | ||
| |
Manifest | ||
| |
README | ||
| |
Rakefile | ||
| |
TODO | ||
| |
lib/ | ||
| |
render-caching.gemspec | ||
| |
script/ | ||
| |
spec/ | ||
| |
tasks/ |
= Render Caching
Cache render calls in Rails controllers.
== Install
First install the gem.
gem install ryanb-render-caching --source=http://gems.github.com
Then specify it in your Rails config.
config.gem 'ryanb-render-caching', :lib => 'render_caching', :source => 'http://gems.github.com'
Rails 2.1 or later required.
== Usage
This gem adds the render_with_cache method to all controllers. Call
this inside of an action to cache the view.
def show
@user = User.find(params[:id])
render_with_cache
end
This will cache the full rendered contents into a key matching the URL
path (similar to action caching). You can change this key by simply
passing any parameter.
def show
@user = User.find(params[:id])
render_with_cache @user.cache_key
end
Cache key is a method supplied by Rails. This includes the updated_at
time which will give you an auto-expiring cache when the user record is
updated.
You can also supply a block to the render call which will only get
executed if there is no cache. Here is a good place to do any custom
render calls.
def show
@user = User.find(params[:id])
render_with_cache @user.cache_key do
render :layout => false
end
end
== Development
This project can be found on github at the following URL.
http://github.com/ryanb/render-caching/
If you would like to contribute to this project, please fork the
repository and send me a pull request.












