开发者

Rails memcached: Where to begin?

I read a few tutorials on getting memcached set up with Rails (2.3.5), and I'm a bit lost.

Here's what I need to cache: I have user-specific settings that are stored in the db. The settings are queried in the ApplicationController meaning that a query is running per-request.

I understand that Rails has built-in support for SQL cacheing, however the cacheing only lasts for the duration of an Action.

I want an easy way to p开发者_Python百科ersist the settings (which are also ActiveRecord models) for an arbitrary amount of time. Bonus points if I can also easily reset the cache anytime a setting changes.

thanks


Gregg Pollack of RailsEnvy did a series of "Scaling Rails" screencasts a while back, which are now free (thanks to sponsorship by NewRelic). You might want to start with episode 1, but episode 8 covers memcached specifically:

http://railslab.newrelic.com/2009/02/19/episode-8-memcached


Sounds like what you want is an object cache between the DB and ActiveRecord. The only decent one we've found so far is Identity Cache (https://github.com/Shopify/identity_cache). It's brand new so it's a bit rough around the edges, but gets the job done for basic caching.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜