mperham/dalli — Issue #159: logger is nil in dalli_store thus not returning nor raising error
Author: xlash
Created: 2012-01-18 05:25:09+00:00
State: open

I had a problem, where my cache key was too long (>250 chars). Instead of getting the appropriate error back in my app, I was getting this :

2012-01-18T04:56:46+00:00 app[web.1]: mc9.ec2.northscale.net:11211 failed (count: 0)
2012-01-18T04:56:46+00:00 app[web.1]: Dalli/SASL authenticating as app1772472%40heroku.com
2012-01-18T04:56:46+00:00 app[web.1]: Dalli/SASL: Authenticated
2012-01-18T04:56:46+00:00 app[web.1]: mc9.ec2.northscale.net:11211 failed (count: 0)
2012-01-18T04:56:46+00:00 app[web.1]: Dalli/SASL authenticating as app1772472%40heroku.com
2012-01-18T04:56:46+00:00 app[web.1]: Dalli/SASL: Authenticated
2012-01-18T04:56:46+00:00 app[web.1]:
2012-01-18T04:56:46+00:00 app[web.1]: NoMethodError (undefined method `error' for nil:NilClass):
2012-01-18T04:56:46+00:00 app[web.1]: app/controllers/myapp_controller.rb:405

The problem is related to

In dalli-1.1.4/lib/active_support/cache/dalli_store23.rb

# Read an entry from the cache.
def read(key, options = nil) # :nodoc:
super
@data.get(escape_key(key), options)
rescue Dalli::DalliError => e
logger.error("DalliError: #{e.message}")
nil
end

logger.error does not work because logger is nil

Using Rails 3.1, Dalli-1.1.4. Problem was happening on heroku