# What's the good way to cache reference data?

**URL:** <https://www.ruby-forum.com/t/whats-the-good-way-to-cache-reference-data/112016>\
**Category:** Rails\
**Created:** [August 14, 2007, 10:43am UTC](https://www.ruby-forum.com/t/whats-the-good-way-to-cache-reference-data/112016 "2007-08-14T10:43:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexeyv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/46a35a/32.png) [@alexeyv](https://www.ruby-forum.com/u/alexeyv)\
**Post date:** [August 14, 2007, 10:43am UTC](https://www.ruby-forum.com/t/whats-the-good-way-to-cache-reference-data/112016/1 "2007-08-14T10:43:13Z")

</div>

I’m looking at an application that has 30+ lookup tables. By that I  
mean your typical (id, description, created\_on) affairs that contain  
locations, zip codes, contract types and what not. Things that rarely  
change, and are maintained by administrators.

It’s well known that when you have many lookup tables in the schema,  
eager loading is not good enough anymore, and you need to cache them  
in memory as ready-made objects, to avoid abusing the database.

Looking for an available Rails solution I came across  
[http://dev.robotcoop.com/Libraries/cached\_model/classes/CachedModel.html](http://dev.robotcoop.com/Libraries/cached_model/classes/CachedModel.html)

Is it the good way to do this? Are there other choices worth looking  
at? Should we roll our own?

NB: Yes, I know about ActiveRecord:Base.cache(), and it doesn’t solve  
this problem, not in our case.

–  
Alexey V.  
CruiseControl.rb [[http://cruisecontrolrb.thoughtworks.com](http://cruisecontrolrb.thoughtworks.com)]  
RubyWorks [[http://rubyworks.thoughtworks.com](http://rubyworks.thoughtworks.com)]

---

<div class="post-metadata">

**Author:** ![alexeyv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/46a35a/32.png) [@alexeyv](https://www.ruby-forum.com/u/alexeyv)\
**Post date:** [August 14, 2007, 1:34pm UTC](https://www.ruby-forum.com/t/whats-the-good-way-to-cache-reference-data/112016/2 "2007-08-14T13:34:46Z")

</div>

Alexey V. wrote:

> [http://dev.robotcoop.com/Libraries/cached\_model/classes/CachedModel.html](http://dev.robotcoop.com/Libraries/cached_model/classes/CachedModel.html)
> 
> Is it the good way to do this? Are there other choices worth looking  
> at? Should we roll our own?

For smallish tables that you want permanently and fully cached in memory  
I’d recommend:  
[http://svn.protocool.com/public/plugins/enumerations\_mixin/](http://svn.protocool.com/public/plugins/enumerations_mixin/)

–  
We develop, watch us RoR, in numbers too big to ignore.
