开发者

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

开发者 https://www.devze.com 2023-01-01 09:09 出处:网络
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:

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

精彩评论

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

关注公众号