Infinispan can use a CacheLoader
interface to save the in-memory cache data to a persistent cache store, such as a database or text file. And during initialization, CacheLoader
can pre-load the cache using data from the persistent cache store.
The following figure shows an Infinispan instance using a backend store:
The entries are fetched from the store lazily, when the get()
operation can't find the value in the cache the cache loader enters in action. The object returned by CacheLoader
will be stored into the cache and reused as a response to the get()
request.
Once the entry is in the memory available for modifications, the underlying cache store is notified about any changes in the cache entry, so that the entries are properly synchronized in the persistent store.