cached_models provides to your models a transparent approach to use Rails internal cache mechanism.

Usually, when you decide to use cache for your ActiveRecord results, you have to manually implement complex expiring policies. cached_models simplifies your code:
class Author true end

class Post true end

That’s all!!.

A more complex example..
class Project true

has_many :tickets, :cached => true has_many :recent_tickets, :limit => 5, :order => ‘id DESC’, :cached => true end

class Developer true end

Example 1

project.developers # Database fetch and automatic cache storing

developer = project.developers.last developer.update_attributes :first_name => ‘Luca’ # Database update and cache expiration for project cache

Example 2

# Fetch associated collection for both the projects project.developers project2.developers

developer = project.developers.last project2.developers

Example 3

project.tickets # Database fetch and automatic cache storing ticket = project.recent_tickets.first ticket.update_attributes :state => 'solved' # Database update and cache expiration for both tickets and recent_tickets entries

The current version works only with the has_many macro.

How to install

$ ./script/plugin install git://github.com/jodosha/cached_models.git

Official page

http://lucaguidi.com/pages/cached_models