views:

165

answers:

1

Hi,

In my Rails app, I changed my model's find method to search into the cache before looking 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

A: 

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.

x1a4