Update: Check out my presentation from RailsConf 2007 for even more caching fun.
Tuesday night I gave a presentationish thing at the San Francisco Ruby Meetup on memcached. It was a lot of fun, and Microsoft hosted it. Microsoft hosting a Ruby meetup. Sun hiring the JRuby Crew. Anyone else feel like we’re being tricked?! Get me my tinfoil hat.
The meetup was great. Lots of cool people. Amazing questions and discussion. I wish you could have been there. You couldn’t, so I’m putting my slides up as a PDF. While I’ve included notes, there were so many great ideas and points raised during the presentation by Ruby dudes that you truly are getting the shaft. My apologies.
Much of my talk focused on memcached concepts, tricks, caveats, and experiences. I also used it as a selfish opportunity to promote a new plugin: acts_as_cached. We’re using this monster on Chowhound and Chow and it’s really working well for us. There are many places I would like to take it, many things I would like to improve, but it works. The tests all pass. Just, uh, ignore that one test I commented out. It doesn’t pass.
Some usage idioms can be gleaned from the README. There’s more code in there than in the presentation, which I tried to keep somewhat abstract. Ideas, people.
Get the presentation:
Install the plugin:
$ cd RAILS_ROOT
$ ruby script/plugin install \ svn://errtheblog.com/svn/plugins/acts_as_cached
It’ll try to help you out by telling you if it can’t find any dependencies. Here they are:
- memcached. Follow topfunky’s guide to get the daemon.
- memcache-client: $ sudo gem install memcache-client
When you install the plugin it copies memcached.yml into your config/ directory. Check it out and tweak the settings to your liking. Start your memcached daemon, start your Rails app, then get caching!
I realize memcached is a beast. Here’s the deal: if you have a great idiom or idea, post it in the comments. If you have a bug fix, complaint, or question: join the acts_as_cached mailing list. Thanks.