This project is archived and is in readonly mode.

#2854 ✓resolved
ekolve

ActiveSupport::Cache::MemCacheStore connection to MemCached becomes corrupted with invalid :expires_in

Reported by ekolve | June 29th, 2009 @ 09:21 PM | in 2.x

If the following code is run the first write succeeds, but the last two calls output an error in the logs:

Cache write: foo
Cache read: foo
Cache write: mynewfoo ({:expires_in=>"Mon Jun 29 13:10:40 -0700 2009"})
MemCacheError ():
Cache read: foo
MemCacheError ():

The invalid expires_in corrupts the connection to MemCache. The simplest fix to this would be to call reset on the connection to memcache and retrieve a new connection if a MemCache exception is rescued.


cache = ActiveSupport::Cache::MemCacheStore.new("localhost:11211")

cache.write("foo", "bar")

puts cache.read("foo").inspect # outputs foo

cache.write("mynewfoo", "blah", :expires_in => 'Mon Jun 29 13:10:40 -0700 2009')

puts cache.read("foo").inspect # outputs nil

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages