Skip to content
This repository was archived by the owner on Jan 3, 2018. It is now read-only.
/ will_cache Public archive

(Wannabe) Drop-in replacement for cache_fu that uses Rails.cache store

License

Notifications You must be signed in to change notification settings

dejan/will_cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

(Wannabe) Drop-in replacement for cache_fu that uses Rails.cache store

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages