I'm using rails 3.2 and Ruby 1.9.3
I have a need to store data in Redis for caching purposes. The data element I want to save is a hash of different types of elements -- some of which are currently ActiveRecord objects.
I want to store this compound object in redis (an in-memory key/value store). To do so I need to serialize / deserialize the compound object in a way that brings it back together correctly.
How can I serialize or marshal this hash so it comes back together into the same set of objects when I pull it out of cache?
Try using Marshal.dump(obj) and Marshal.load(marshal_str). Here are the DOCS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With