I want to cache a huge number of items very quickly and space efficiently.
So I wrote a cache that consists of an
Box<Vec<u8>> for storing the state in compressed form and a
HashMap<StateKey, StateInfo> where the StateKey has indices into the vec and StateInfo is just the part of the State i am interested in storing.
This is self referential and therefore i needed some unsafe in the implementation of StateKey.
I thought about it for quite some time and i think this should be safe but i am no unsafe guru so the question is, is this actually safe?
I would also be interested in safe alternatives that don't result in loosing a lot of perf.
I wish i could use bumpalo but I need the ability drop the most recent allocation.