# Cached\_models

**URL:** <https://www.ruby-forum.com/t/cached-models/148283>\
**Category:** Rails\
**Created:** [September 11, 2008, 9:51am UTC](https://www.ruby-forum.com/t/cached-models/148283 "2008-09-11T09:51:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikbauer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@erikbauer](https://www.ruby-forum.com/u/erikbauer)\
**Post date:** [September 11, 2008, 9:51am UTC](https://www.ruby-forum.com/t/cached-models/148283/1 "2008-09-11T09:51:15Z")

</div>

Hi all,  
Yesterday I released a new Rails plugin: cached\_models.  
It allows to transparently use the internal Rails cache mechanism in  
your models, avoiding to write code for expiring policies.

Example

class Project \< ActiveRecord::Base  
has\_many :developers, :cached =\> true  
end

class Developer \< ActiveRecord::Base  
belongs\_to :project, :cached =\> true  
end

# Automatic cache, all the following calls will be served by the cache.

project.developers

developer = project.developers.first  
developer.update\_attributes :first\_name =\> ‘Luca’

# Database update and cache expiring for project.

project2.developers \<\< developer

# Database update and cache expiring for project and project2

This is a 0.0.1 release, it actually support only the has\_many relation.  
BTW I’d really like to receive a lot of feedbacks and comments.

You can find all the documentation here: [http://tinyurl.com/6e3mwk](http://tinyurl.com/6e3mwk)

## Ciao, -luca

blog: [www.lucaguidi.com](http://www.lucaguidi.com)  
Pro-Netics: [www.pro-netics.com](http://www.pro-netics.com)  
Sourcesense - making sense of Open Source: [www.sourcesense.com](http://www.sourcesense.com)

---

<div class="post-metadata">

**Author:** ![erikbauer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c77e96/32.png) [@erikbauer](https://www.ruby-forum.com/u/erikbauer)\
**Post date:** [September 11, 2008, 10:05am UTC](https://www.ruby-forum.com/t/cached-models/148283/2 "2008-09-11T10:05:18Z")

</div>

On Thu, Sep 11, 2008 at 12:47 AM, Luca G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> end  
> developer.update\_attributes :first\_name =\> ‘Luca’
> 
> # Database update and cache expiring for project.
> 
> project2.developers \<\< developer
> 
> # Database update and cache expiring for project and project2
> 
> This is a 0.0.1 release, it actually support only the has\_many relation.  
> BTW I’d really like to receive a lot of feedbacks and comments.

You can find all the documentation here: [http://tinyurl.com/6e3mwk](http://tinyurl.com/6e3mwk)

> 

Hi, this is good to hear and I’ll check it.

-Conrad
