Workaround the Memcached "undefined class/module" Bug
Posted by Chris Blackburn
If you are experiencing the error: “undefined class/module MyClass” when fetching data from memcached, be assured that you are not alone. It is a known bug and the simplest way I know of to get around it is to reference the class or classes right before you retrieve data from the cache.
For example, if the following code causes the problem:
if not (genres = Cache.get(key))
genres = Genre.find(:all, :condition => "platform_id = 1")
Cache.put(key, genres, 60*60*24) # cache for 1 day
end… then this code will work around it:
Genre
if not (genres = Cache.get(key))
genres = Genre.find(:all, :condition => "platform_id = 1")
Cache.put(key, genres, 60*60*24) # cache for 1 day
endNotice the ‘Genre’ reference before the if statement. Some have reported success by using the ‘model’ statement within the controller, however that is deprecated. This workaround will get you going again.

