Trying to introduce caching/state-persisting into the middle tier of an application with a complex object layer (and a WCF service layer, not the focus here) running under IIS. Have settled on memcached/enyim as the caching architecture, and now need to get these objects serialized efficiently (speed and space) for it.
The object layer has a lot of pointers and interdependencies among objects, along these lines:
internal class SomeObj
{
private string attr1;
private int attr2;
private OtherObj otherObj;
private List<OtherOtherObj> otherObjs;
}
internal class OtherObj
{
//...more attributes
}
internal class OtherOtherObj
{
// you get the idea
}
Note that all fields are private. Also worth noting, most objects are internal, and many properties are either read-only (no set) or use set from a user perspective (i.e. make an object "dirty"), so cannot be used in rehydration. I have dozens of types that need caching.
I like the looks of both protobuf-net and msgpack, but I need to get the serialization done as fast as possible, with as little alteration of the existing architecture (which works well as is) as possible, and it seems like both of these have limited support for object hierarchies. I understand DTO-type serialization well, but am new to planning the right way to serialize an object for a cache. Can one of these tools work for me? Am I stuck using built-in .NET binary in order to work with a constructor, and repopulate attributes and objects on my own terms?
EDIT: just to clarify that last question--might make more sense if it read "Am I stuck using built-in .NET binary so that I can control the constructor, and repopulate attributes and objects on my own terms?