Interface MapStore<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Known Subinterfaces:
EntryStore<K,V>
- All Known Implementing Classes:
JCacheWriterToMapStoreAdapter, JdbcGenericMapStore
public interface MapStore<K,V>
Service Provider Interface (SPI) for plugging an external persistent backing
store into a
DistributedMap.
Implementations are expected to be thread-safe: LoomCache invokes the store from multiple threads (write-behind flusher + user-visible ops when write-through is enabled) and never serializes access internally.
Failures are surfaced as unchecked exceptions to the caller when the
store is configured for write-through; under write-behind they are caught
and counted into
CacheMetrics.writeThroughFailureCount()
/
CacheMetrics.deleteThroughFailureCount().
Default loadAll / storeAll / deleteAll /
loadAllKeys implementations are provided so that minimal stores only
need to implement the three single-key methods.
-
Method Summary
Modifier and TypeMethodDescriptionvoidRemove a single key from the backing store.default voiddeleteAll(Collection<? extends K> keys) Remove multiple keys.@Nullable VLoad the value associated withkeyfrom the backing store.loadAll(Collection<? extends K> keys) Load multiple values in one round-trip.Stream every key known to the backing store.voidPersist a single key/value pair.default voidPersist multiple key/value pairs.
-
Method Details
-
load
-
loadAll
Load multiple values in one round-trip. Default implementation loopsload(Object); override for efficiency when the store supports bulk reads.- Parameters:
keys- keys to load (nevernull; may contain no duplicates)- Returns:
- a map containing only keys for which a non-null value was loaded
-
loadAllKeys
-
store
-
storeAll
Persist multiple key/value pairs. Default implementation loopsstore(Object, Object); override for efficiency when the store supports bulk writes.- Parameters:
map- entries to persist (nevernull)
-
delete
Remove a single key from the backing store. No-op when the key is absent.- Parameters:
key- the key to delete (nevernull)
-
deleteAll
Remove multiple keys. Default implementation loopsdelete(Object); override for efficiency when the store supports bulk deletes.- Parameters:
keys- keys to delete (nevernull)
-