I have some JObjects which I need to cache, and I wonder what best practice is when caching such data in CacheManager?
I'm concerned with
- Using a reasonably small amount of memory in the cache.
- Not unnecessarily serialize to avoid useless processing.
If I cache the json string
I need to parse it every time I read the cache.
If I cache the JObject
I don't know how it will be serialized to the cache. Probably as a non-compact binary array. But I won't have to do anything to it after retrieving it.
That's why I'm considering that perhaps it will serialize Bson
better, or maybe that's going to simply add another layer of serialization? After all, I'll have to convert the Bson
to JObject
when reading the cache, much like if I were to cache the json string
.