'How to implement a persistent cache-like java module

I have a lot of objects which are used by my algorithm. Saving all these objects in memory is not feasible. How can I implement in java a module which can be used as a key-value "database" with a predefined memory usage limitation.

I am thinking of a cache-like module which holds these objects in-memory, like a simple cache, but instead of evicting the objects, saving them in the file system, and not loosing them (I cannot loose these objects during the execution on the algorithm).

When the algorithm request a specific object which does not exist in memory, the module will fetch the object from the file-system.

These objects should be persistent for later executions of the algorithm.

Any suggestions about best-practices how to implement such module?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source