开发者

How do I handle Memcached::ServerIsMarkedDead error with Rails?

In my Rails app, I changed my model's find method to search into the cache before lookin开发者_Python百科g into the database, but I sometime get this error:

Memcached::ServerIsMarkedDead

While waiting for Memcached server to be up again, how should I handle this error and force Rails to search into the database?

Thank you,

Kevin


You should be able to just rescue the exception and search the database in that case.

Rails.cache.fetch encapsulates this pattern in a more generic way, and you may want to look into that instead of hacking find, which is likely to bite you soon when Rails 3 comes out.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜