Fast, light-weight, session-based, redis-backed Rails caching.
Ruby JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
Gemfile
Gemfile.lock
MIT-LICENSE
README.md
Rakefile
cachemere.gemspec
init.rb

README.md

Cachemere

A simple, redis-backed caching plugin for Rails.

What is it for?
It's mainly for caching read-only API calls for a set-period of time.

What does it do?
It caches controller actions based on type, and can expire the cache whenever you want.

But Rails already has caching built-in...
Yes, but it doesn't auto-expire the files it writes to disk. Also, because Cachemere is redis-backed, it uses mainly RAM to access cached files.

Usage

Step 0
Install redis and the redis gem.

Step 1
Add Cachemere to your Gemfile (and bundle install if necessary)

gem 'cachemere'

Step 2
In your controller, create a before and after filter for Cachemere.

before_filter :cache_start  
after_filter :cache_end

Step 3
Create the above filters and start caching!

def cache_start  
  Cachemere::start_caching request, :json, self
  # Where ":json" is the response type
end

def cache_end
  Cachemere::end_caching response, 60
  # Where '60' is how long you want to keep the cache for (in seconds)
end

Step 4
All done! Happy caching!

Author

Kishyr Ramdial
Head of R&D
immedia


Licence

Copyright (c) 2011, Kishyr Ramdial.
All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.