Rails插件

Rails插件

[ 7 主题 / 10 回复 ]
版主:
下一个帖子 上一个帖子 您是本帖的第 299 个阅读者 推荐 举报 打印
主题:cache money 插件 twitter 贡献给 rails 社区的一个缓存插件

aotianlong 发表于 大约一年 第1楼

中文翻译地址:

http://www.javaeye.com/news/4480-twitter-gives-back-some-cache-to-rails


英文地址:
http://www.railsinside.com/tools/174-twitter-gives-back-some-cache-to-rails.html

Twitter Gives Back Some Cache to Rails
One Comment
By Mike Gunderloy on December 12th, 2008 in Tools

Over the past couple of years Twitter has been something of a poster child for Rails - and not always in a good way. When they were having performance issues, they were exhibit #1 for the "Rails Can't Scale" camp. But the Twitter performance problems seem to be mainly a thing of the past. Now they're contributing some of their solutions back to the wider Rails community.

The giveback is in the form of cache-money, a write-through caching library for Active Record (announced in a blog entry by Twitter's Nick Kallen). If you need a refresher on write-through caching, it's pretty simple: every write to the cache causes a synchronous write to the backing store. In this case, the backing store is your actual database, and the cache is Memcached. With write-through caching, you need not worry about cache invalidation; if something changes, it gets written to the cache and to the database at the same time.

To use cache-money, you install the gem and set up an initializer. Then you need to go through your ActiveRecord models and indicate the indices that will be used - and that's it. The rest happens automatically.

cache-money can't handle every possible query; it's optimized for speed and handling the most common cases. The cases it handles should be enough for many Active Record operations: find, find_all, hash, array, and string conditions, and more. The unsupported operations will just fall through the cache to the underlying data.

This isn't a panacea that will fix every Rails scaling issue, but it looks a whole lot simpler to use than something like cache-fu. The current code is marked as a release candidate; it's been extracted from the Twitter codebase and has a few to-do items left, though nothing that would block its use in many production environments.
标签:
Sigline
技术狂人一个,没啥商业头脑。 都快奔三了,还是啥都没有。

aotianlong 发表于 大约一年 第1楼

代码库
http://github.com/nkallen/cache-money/tree/master

Sigline
技术狂人一个,没啥商业头脑。 都快奔三了,还是啥都没有。