Record Class MapStoreBackedCacheWriter<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
CacheWriterIntegration.BackingStoreWriter<K,V>
MapStore as a
CacheWriterIntegration.BackingStoreWriter, letting JCache
(JSR-107) write-through / write-behind reuse the same SPI as
DistributedMap.setMapStore(MapStore, MapStoreConfig).
The adapter intentionally delegates ONLY write(Object, Object)
— BackingStoreWriter is a single-method functional interface;
CacheWriterIntegration does not model a delete path today. Deletes
continue to flow through whatever JCache-side CacheWriter
configuration callers wire up.
Write-behind double-buffering warning. When this adapter wraps a
MapStore that is already configured for write-behind on a
DistributedMap, and the
surrounding CacheWriterIntegration is ALSO created in write-behind
mode, writes traverse two independent schedulers (the JCache queue, then
the DistributedMap queue) with two batch/flush cycles, two retry budgets
and two sets of metrics. That configuration is legal but rarely what
operators want. Prefer one of:
- Configure JCache write-behind and wrap a
MapStorethat usesMapStoreConfig.writeThroughConfig()— JCache owns the async semantics, the store sees synchronous calls. - Configure JCache write-through and let a write-behind
MapStoreConfigown the async semantics.
The adapter is thread-safe iff the wrapped MapStore is, which is
a hard requirement of the MapStore SPI contract.
-
Constructor Summary
ConstructorsConstructorDescriptionMapStoreBackedCacheWriter(MapStore<K, V> mapStore) Wrap aMapStoreas aCacheWriterIntegration.BackingStoreWriter. -
Method Summary
Modifier and TypeMethodDescriptionvoidDelete a key via the wrappedMapStore.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable VLoad a value via the wrappedMapStore.mapStore()Expose the underlyingMapStorefor diagnostics / advanced callers that need to issue reads or deletes outside theCacheWriterIntegrationwrite path.final StringtoString()Returns a string representation of this record class.voidDelegate a write toMapStore.store(Object, Object).
-
Constructor Details
-
MapStoreBackedCacheWriter
Wrap aMapStoreas aCacheWriterIntegration.BackingStoreWriter.- Parameters:
mapStore- the backing store to delegate to (nevernull)
-
-
Method Details
-
write
Delegate a write toMapStore.store(Object, Object). TheCacheWriterIntegrationcontract forbids null key/value, so we pass through and let the store enforce its own invariants.- Specified by:
writein interfaceCacheWriterIntegration.BackingStoreWriter<K,V> - Parameters:
key- the key (nevernullwhen invoked throughCacheWriterIntegration.write(Object, Object))value- the value (nevernullwhen invoked throughCacheWriterIntegration.write(Object, Object))
-
mapStore
Expose the underlyingMapStorefor diagnostics / advanced callers that need to issue reads or deletes outside theCacheWriterIntegrationwrite path.- Returns:
- the wrapped store (never
null)
-
load
-
delete
Delete a key via the wrappedMapStore. Convenience for callers that want the adapter to also serve write-through-deletes without reaching into(). Not invoked byCacheWriterIntegrationitself — that class has no delete path.- Parameters:
key- the key to delete (nevernull)
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object).
-