Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
(Wannabe) Drop-in replacement for cache_fu that uses Rails.cache store
Ruby
tree: 4568f8f2bf

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
MIT-LICENCE
README.md
Rakefile
init.rb
will_cache.gemspec

README.md

WillCache

WillCache provides simple API for caching ActiveRecord objects that uses ActiveSupport Cache Store internally so that it's trivial to switch cache storage. WillCache API is heavily inspired by excellent but no longer maintained cache_fu plugin and one of the goals of the gem is to provide drop-in replacement for it.

Example usage

>> User.last.cached(:profile)
  User Load (0.000581) (1 Row)   SELECT * FROM `users` ORDER BY users.id DESC LIMIT 1
  Cache miss: User:65:profile
  Profile Load (0.000454) (1 Row)   SELECT * FROM `profiles` WHERE (`profiles`.user_id = 65) LIMIT 1
  Cache write (will save 1.64ms): User:65:profile
=> #<Profile id: 65, first_name: nil, last_name: nil, ...>

Example shows inline log in Rails console.

Install

Specify the gem in Gemfile of the project

gem "will_cache"

Credits

Author: Dejan Simic

Initial development of the gem was sponsored by LessEverything

Something went wrong with that request. Please try again.