Class MapDBCache

All Implemented Interfaces:
AutoCloseable, Cache<PersistentCacheKey,CompletableFuture<? extends DataRetrievalResponse<?>>>

Persistent cache backed by a MapDB HTreeMap.

This class is thread-safe for concurrent access through its public methods on a single MapDBCache instance. All access is guarded by synchronization on map.

Cache entry creation, invalidation, and replacement behavior are delegated to the configured cache policies.

The cache enforces a maximum capacity. If the persisted map contains more entries than allowed when opened, entries are evicted according to the configured replacement policy until the capacity constraint is satisfied.

Caveats:

Thread safety is provided only at the level of this cache instance. If two MapDBCache objects point to the same persisted file, this class does not coordinate:

  • replacement policy state
  • capacity enforcement
  • invalidation/eviction decisions