I am creating an IMAP web client in Rails and want to cache an IMAP object between requests. I planned to serialize the object and save it in Redis (since it only caches strings), however, none of the popular serialization methods seem to work.
Marshall and ActiveSupport :: Cache :: MemoryStore both result in the following error:
Marshal.dump(imap)
TypeError: no marshal_dump is defined for class Mutex
YAML serialization works, but deserialization fails.
s = YAML::dump(imap)
imap2 = YAML::load(s)
TypeError: allocator undefined for Thread
Is there another alternative caching mechanism that works for any ruby objects, especially those that can use streams inside? Does the alternative keystore (I used Redis) support such caching? Even better, is there Rails for remembering certain objects, and not for deserializing them?
PS > Ruby 1.9.2 Rails 3.0.3 Macbook, .