Ruby, JavaScript, Sass, iOS. Stinky Cheese & Beer Advocate. Working at CustomInk and loving it!

757rb Memcached Talk

757.rb Memcached Presentation Earlier this week I gave a talk at our local ruby users group, 757.rb, about Memcached. Here recently I started picking it up again so that I could keep track of large sets of PK/FK changes during a big database move. In doing so, I decided to dig deep into it's internals and get a better grasp of how I would use it when I decided to do some serious fragment caching again.

The biggest thing I took away from the talk was -- First, that you can use an array of strings/objects for the key passed to various caching methods. If the object responds to #cache_key, the return of that method would be used. The default implementation of ActiveRecord's #cache_key method is to use the updated_at column for a unique timestamp. It is even smart enough to know weather the object is new or not. Thanks to Brennan Dunn for pointing that out! The second and most important thing was an article by Nahum Wild that talked about item level caching. This seemed like a strange place to start as typically I would start with a page or big sections of fragments. But as the demo app shows, this is an incredibly good place to start. Especially if you have heavy hitting pages of paginated views that talk to deep nested associations.

Resources