Class WriteThroughCacheStore
Every cache write (PUT, DELETE) is synchronously persisted to the database via Spring Data JPA BEFORE the cache operation returns to the client.
-
Constructor Summary
ConstructorsConstructorDescriptionWriteThroughCacheStore(CacheEntryRepository repository, String nodeId, int instanceNumber) Construct the write-through cache store. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear all persisted entries for a map.longCount persisted entries for a map.voidDelete-through: remove a cache entry from the database.@Nullable StringLoad a value from the database (read-through / warm-up).Load all entries for a map (full cache warm-up) using paginated queries.voidWrite-through: persist a cache entry to the database.
-
Constructor Details
-
WriteThroughCacheStore
Construct the write-through cache store.- Parameters:
repository- the cache entry repository (not null)nodeId- the node identifier (not null)instanceNumber- the instance number for logging
-
-
Method Details
-
store
-
delete
-
load
-
loadAll
Load all entries for a map (full cache warm-up) using paginated queries.Entries are loaded in pages of 1000 to prevent OOM when millions of entries exist in the database.
Recovery-envelope contract: if the persisted row count exceeds
LOAD_ALL_MAX_ENTRIESwe throwIllegalStateExceptionrather than silently truncating — a partial recovery would return a node to service with missing data, which operators must never receive as "healthy". Either raise the cap, shard the map, or remove persisted rows before restart.Fail-closed on DB errors: a
DataAccessExceptionraised mid-iteration is rethrown asLoomExceptionrather than silently returning the partial page set collected so far. Returning a partial map would warm the cache with an arbitrary subset of keys — subsequent reads for the missing keys would miss and re-fetch from origin (best case) or returnnullfor keys that do exist in the DB (worst case). Both are silent correctness failures. Propagating aborts node warm-up, which is the same posture as the row-count cap above. -
clearAll
Clear all persisted entries for a map. -
count
Count persisted entries for a map.
-