Create named classes for cache objects

This makes heampdump and coredump analysis dramatically easier as cached entries will appear in the respective tools as `MemoryCacheSegement` and `MemoryCacheEntry` rather than generic objects. This allows for much simpler analysis of the memory impact of the cache as a whole.
The existing `try` handles that. Doing that was easier than localizing it in here as the `callback` flow control needs to manage the caller more than this specific function.