I am involved in an effort to replace System.Web.Caching.Cache with Redis. The issue I am running into is that while System.Web.Caching.Cache seems to be able to cache just about whatever object I pass to it, Redis is string-based. This means that I have to worry about serialization myself.
The two approaches I've tried are 1) to use JSON.NET to serialize my objects to a string, and 2) to use BinaryFormatter. The JSON.NET approach can probably be made to work, but of course there are many configuration points (around what to serialize/ignore, how to handle reference loops, etc.) and making this approach work has turned into a fair amount of work.
The BinaryFormatter approach, I had suspected, was probably closer to what System.Web.Caching.Cache was doing internally. Having gone down that path a bit, though, I am not so sure of that anymore. Many types I'm trying to cache are not marked [Serializable], which seems to rule out BinaryFormatter.
I am wondering if anyone else has faced similar issues, or knows what System.Web.Caching.Cache is doing internally so that I can emulate it. Thanks.