Interface DistributedPolicy<K,V>
-
- Type Parameters:
K
- the key type of the cacheV
- the value type of the cache
public interface DistributedPolicy<K,V>
Interface representing an access point for inspecting and performing low-level operations on the cache instance (similar toPolicy
).
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DistributedPolicy.CacheEntry<K,V>
Interface representing a cache entry containing key and value along with some metadata.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<DistributedPolicy.CacheEntry<K,V>>
getAllFromMongo(Iterable<? extends K> keys, boolean includeEvicted)
Get the cache entries mapped to the specified keys directly from the MongoDB collection bypassing this cache instance.DistributedPolicy.CacheEntry<K,V>
getFromMongo(K key, boolean includeEvicted)
Get the cache entry mapped to the specified key directly from the MongoDB collection bypassing this cache instance.com.mongodb.client.MongoCollection<org.bson.Document>
getMongoCollection()
Get the MongoDB collection used for distributed synchronization between cache instances.void
startSynchronization()
Start distributed synchronization for this cache instance if it was stopped before.void
stopSynchronization()
Stop distributed synchronization for this cache instance.
-
-
-
Method Detail
-
getMongoCollection
com.mongodb.client.MongoCollection<org.bson.Document> getMongoCollection()
Get the MongoDB collection used for distributed synchronization between cache instances.- Returns:
- the
MongoCollection
-
startSynchronization
void startSynchronization()
Start distributed synchronization for this cache instance if it was stopped before. After starting, changes to this cache instance are distributed to other cache instances and changes to other cache instances are distributed to this cache instance. Persisted cache entries from the MongoDB collection are synchronized into this cache instance with priority (only if the configuredDistributionMode
includes population), so that previously existing cache entries in this cache instance might be overwritten or removed.
-
stopSynchronization
void stopSynchronization()
Stop distributed synchronization for this cache instance. After stopping, changes to this cache instance are not distributed to other cache instances, nor are changes to other cache instances distributed to this cache instance. Therefore, this cache instance behaves like a cache instance without distributed synchronization functionality.
-
getFromMongo
DistributedPolicy.CacheEntry<K,V> getFromMongo(K key, boolean includeEvicted)
Get the cache entry mapped to the specified key directly from the MongoDB collection bypassing this cache instance. If desired, already evicted cache entries can also be included.- Parameters:
key
- the key whose associated cache entry is to be returnedincludeEvicted
-true
if evicted cache entries should also be included,false
otherwise- Returns:
- the cache entry to which the specified key is mapped, or null if no mapping for the key is found
-
getAllFromMongo
List<DistributedPolicy.CacheEntry<K,V>> getAllFromMongo(Iterable<? extends K> keys, boolean includeEvicted)
Get the cache entries mapped to the specified keys directly from the MongoDB collection bypassing this cache instance. If desired, already evicted cache entries can also be included.- Parameters:
keys
- the keys whose associated cache entries are to be returnedincludeEvicted
-true
if evicted cache entries should also be included,false
otherwise- Returns:
- a list of cache entries to which the specified keys are mapped
-
-