> That might be just slightly unsafe, don't you think, if a piece of data > gets evicted before it's needed? I'd prefer to limit caching to data that > can be recreated when it's not found in the cache. > > An alternative might be a memory-based SQLite database, taking care not to > let it leak (a consideration regardless of the implementation) >
Thanks for the suggestions. But would a piece of data get removed from the cache arbitrarily/automatically? In other words, if we're sure of the size of data coming in and make sufficiently large cache for storing them, then would it be 100% safe to use cache to keep the data for my case here? Or am I missing something else? Your second suggestion sounds similar to using Redis, in which case would there still be a risk of leaking? Thank you.