Handle Dalli :: RingError - server unavailable in Sinatra

I have a Sinatra application running on Heroku that uses Dalli to support memcached support. Sometimes the memcached server does not respond, and I get the following:

Dalli::RingError - No server available 

What is the best way to handle this situation?

+4
source share
1 answer

I decided to handle this by explicitly ignoring the error, as there are no reasons why the function of my application will not work if the caching component does not work. Of course, you could do the log statement or whatever you want, but I decided not to do anything.

I created my own Cache class and used this to isolate the domain code from Dalli. Here is the relevant part:

 def Cache.get(key) Configuration.dalliClient.get(key) rescue Dalli::RingError nil end 
+3
source

All Articles