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.
精彩评论