
Caching Without Marshal Part 2: The Path to MessagePack - Shopify
11/15/2022
This post details the technical implementation of replacing Ruby's Marshal serialization with MessagePack for caching. It explains the MessagePack format, its core types, and the crucial concept of extension types for handling custom Ruby objects. Specific examples are provided for encoding Date objects and the challenges of serializing ActiveRecord::Base records with associations, leading to the development of an `ActiveRecordCoder`. The post also outlines the migration strategy, including a phased rollout with a version byte prefix and logging of unencodable objects to identify new extension types or problematic cache usage. The core problem addressed is preventing cache corruption due to code changes by using a generic, extensible serialization format.
