Class AbstractDelegatingCache<K,V>
- All Implemented Interfaces:
ConcurrentMap<K,,V> Map<K,,V> Cache<K,,V> org.infinispan.commons.api.AsyncCache<K,,V> org.infinispan.commons.api.BasicCache<K,,V> org.infinispan.commons.api.BatchingCache,org.infinispan.commons.api.Lifecycle,FilteringListenable<K,,V> Listenable
- Direct Known Subclasses:
AbstractDelegatingAdvancedCache
Cache
argument, to which each method call is delegated. One can extend this class and override the method sub-set it is
interested in. There is also an similar implementation for AdvancedCache: AbstractDelegatingAdvancedCache.- Author:
- Mircea.Markus@jboss.com
- See Also:
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<C> voidaddFilteredListener(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Registers a listener limiting the cache-entry specific events only to annotations that are passed in as parameter.<C> CompletionStage<Void>addFilteredListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Asynchronous version ofFilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)voidaddListener(Object listener) Adds a listener to the component.<C> voidaddListener(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter) Registers a listener that will be notified on events that pass the filter condition.addListenerAsync(Object listener) Asynchronous version ofListenable.addListener(Object)<C> CompletionStage<Void>addListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter) Asynchronous version ofFilteringListenable.addListener(Object, CacheEventFilter, CacheEventConverter)<C> voidaddStorageFormatFilteredListener(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Same asFilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set), but assumes the filter and/or the converter will be done in the same data format as it's stored in the cache.<C> CompletionStage<Void>addStorageFormatFilteredListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) voidclear()Removes all mappings from the cache.compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction) computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) booleancontainsKey(Object key) booleancontainsValue(Object value) voidendBatch(boolean successful) entrySet()Returns a set view of the mappings contained in this cache and cache loader across the entire cluster.voidEvicts an entry from the memory of the cache.voidforEach(BiConsumer<? super K, ? super V> action) getAllAsync(Set<?> keys) Retrieves the cache manager responsible for creating this cache instance.Returns String representation of ComponentStatus enumeration in order to avoid class not found exceptions in JMX tools that don't have access to infinispan classes.Deprecated.getName()getOrDefault(Object key, V defaultValue) booleanisEmpty()keySet()Returns a set view of the keys contained in this cache and cache loader across the entire cluster.merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) voidvoidvoidputAll(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) putAllAsync(Map<? extends K, ? extends V> data) putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit unit) putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) voidputForExternalRead(K key, V value) Under special operating behavior, associates the value with the specified key.voidputForExternalRead(K key, V value, long lifespan, TimeUnit unit) An overloaded form ofCache.putForExternalRead(K, V), which takes in lifespan parameters.voidputForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) An overloaded form ofCache.putForExternalRead(K, V), which takes in lifespan parameters.putIfAbsent(K key, V value) putIfAbsent(K key, V value, long lifespan, TimeUnit unit) putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) putIfAbsentAsync(K key, V value) putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit) putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) booleanremoveAsync(Object key) removeAsync(Object key, Object value) voidremoveListener(Object listener) Removes a listener from the component.removeListenerAsync(Object listener) Asynchronous version ofListenable.removeListener(Object)replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) booleanbooleanbooleanreplace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) voidreplaceAll(BiFunction<? super K, ? super V, ? extends V> function) replaceAsync(K key, V value) replaceAsync(K key, V value, long lifespan, TimeUnit unit) replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) replaceAsync(K key, V oldValue, V newValue) replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit) replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) voidshutdown()Performs a controlled, clustered shutdown of the cache.intsize()Returns a count of all elements in this cache and cache loader across the entire cluster.voidstart()booleanvoidstop()Stops a cache.toString()static <K,V> Cache<K, V> unwrapCache(Cache<K, V> cache) Fully unwraps a given cache returning the base cache.values()Returns a collection view of the values contained in this cache across the entire cluster.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.infinispan.commons.api.AsyncCache
containsKeyAsyncMethods inherited from interface org.infinispan.Cache
compute, compute, compute, computeAsync, computeAsync, computeAsync, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, merge, merge, merge, mergeAsync, mergeAsync, mergeAsync
-
Field Details
-
cache
-
-
Constructor Details
-
AbstractDelegatingCache
-
-
Method Details
-
putForExternalRead
Description copied from interface:CacheUnder special operating behavior, associates the value with the specified key.- Only goes through if the
key specified does not exist; no-op otherwise (similar to
ConcurrentMap.putIfAbsent(Object, Object)) - Force asynchronous mode for replication to prevent any blocking.
- invalidation does not take place.
- 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this method is a no-op, and swallows the timeout exception.
- Ongoing transactions are suspended before this call, so failures here will not affect any ongoing transactions.
- Errors and exceptions are 'silent' - logged at a much lower level than normal, and this method does not throw exceptions
- Specified by:
putForExternalReadin interfaceCache<K,V> - Parameters:
key- key with which the specified value is to be associated.value- value to be associated with the specified key.
- Only goes through if the
key specified does not exist; no-op otherwise (similar to
-
putForExternalRead
Description copied from interface:CacheAn overloaded form ofCache.putForExternalRead(K, V), which takes in lifespan parameters.- Specified by:
putForExternalReadin interfaceCache<K,V> - Parameters:
key- key to usevalue- value to storelifespan- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit- unit of measurement for the lifespan
-
putForExternalRead
public void putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:CacheAn overloaded form ofCache.putForExternalRead(K, V), which takes in lifespan parameters.- Specified by:
putForExternalReadin interfaceCache<K,V> - Parameters:
key- key to usevalue- value to storelifespan- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit- time unit for lifespanmaxIdle- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleUnit- time unit for max idle time
-
evict
Description copied from interface:CacheEvicts an entry from the memory of the cache. Note that the entry is not removed from any configured cache stores or any other caches in the cluster (if used in a clustered mode). UseBasicCache.remove(Object)to remove an entry from the entire cache system. This method is designed to evict an entry from memory to free up memory used by the application. This method uses a 0 lock acquisition timeout so it does not block in attempting to acquire locks. It behaves as a no-op if the lock on the entry cannot be acquired immediately. Important: this method should not be called from within a transaction scope. -
getCacheConfiguration
- Specified by:
getCacheConfigurationin interfaceCache<K,V>
-
startBatch
public boolean startBatch()- Specified by:
startBatchin interfaceorg.infinispan.commons.api.BatchingCache
-
endBatch
public void endBatch(boolean successful) - Specified by:
endBatchin interfaceorg.infinispan.commons.api.BatchingCache
-
getName
-
getCacheName
@ManagedAttribute(description="Returns the cache name", displayName="Cache name", dataType=TRAIT) public String getCacheName() -
getVersion
@ManagedAttribute(description="Returns the version of Infinispan", displayName="Infinispan version", dataType=TRAIT) public String getVersion() -
getCacheManager
Description copied from interface:CacheRetrieves the cache manager responsible for creating this cache instance.- Specified by:
getCacheManagerin interfaceCache<K,V> - Returns:
- a cache manager
-
put
-
putIfAbsent
-
putAll
-
replace
-
replace
-
put
-
putIfAbsent
-
putAll
-
replace
-
replace
-
replaceAll
- Specified by:
replaceAllin interfaceConcurrentMap<K,V> - Specified by:
replaceAllin interfaceMap<K,V>
-
putAsync
-
putAsync
-
putAsync
-
putAllAsync
-
putAllAsync
-
putAllAsync
-
clearAsync
-
putIfAbsentAsync
-
putIfAbsentAsync
-
putIfAbsentAsync
-
removeAsync
-
removeAsync
-
replaceAsync
-
replaceAsync
-
replaceAsync
-
replaceAsync
-
replaceAsync
-
replaceAsync
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) -
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) -
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) -
computeIfAbsentAsync
-
computeIfAbsentAsync
-
computeIfAbsentAsync
-
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) -
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) -
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) -
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) -
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) -
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) -
getAdvancedCache
- Specified by:
getAdvancedCachein interfaceCache<K,V>
-
getStatus
-
getCacheStatus
@ManagedAttribute(description="Returns the cache status", displayName="Cache status", dataType=TRAIT) public String getCacheStatus()Returns String representation of ComponentStatus enumeration in order to avoid class not found exceptions in JMX tools that don't have access to infinispan classes. -
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
putIfAbsentin interfaceMap<K,V>
-
remove
-
replace
-
replace
-
size
public int size()Description copied from interface:CacheReturns a count of all elements in this cache and cache loader across the entire cluster. Only a subset of entries is held in memory at a time when using a loader or remote entries, to prevent possible memory issues, however the loading of said entries can still be vary slow. If there are performance concerns then theFlag.SKIP_CACHE_LOADflag should be used to avoid hitting the cache loader in case if this is not needed in the size calculation. Also if you want the local contents only you can use theFlag.CACHE_MODE_LOCALflag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOADis also configured. If this method is used in a transactional context, note this method will not bring additional values into the transaction context and thus objects that haven't yet been read will act in aIsolationLevel.READ_COMMITTEDbehavior irrespective of the configured isolation level. However values that have been previously modified or read that are in the context will be adhered to. e.g. any write modification or any previous read when usingIsolationLevel.REPEATABLE_READThis method should only be used for debugging purposes such as to verify that the cache contains all the keys entered. Any other use involving execution of this method on a production system is not recommended. -
sizeAsync
-
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
compute
Description copied from interface:CacheWhen this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate
Externalizeror beSerializableitself.For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
-
compute
-
compute
-
computeIfPresent
Description copied from interface:CacheWhen this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate
Externalizeror beSerializableitself.For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
- Specified by:
computeIfPresentin interfaceCache<K,V> - Specified by:
computeIfPresentin interfaceConcurrentMap<K,V> - Specified by:
computeIfPresentin interfaceMap<K,V>
-
computeIfPresent
-
computeIfPresent
-
computeIfAbsent
Description copied from interface:CacheWhen this method is used on a clustered cache, either replicated or distributed, the function will be serialized to owning nodes to perform the operation in the most performant way. However this means the function must have an appropriate
Externalizeror beSerializableitself.For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
- Specified by:
computeIfAbsentin interfaceCache<K,V> - Specified by:
computeIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
computeIfAbsentin interfaceMap<K,V>
-
computeIfAbsent
-
computeIfAbsent
-
get
-
getOrDefault
- Specified by:
getOrDefaultin interfaceConcurrentMap<K,V> - Specified by:
getOrDefaultin interfaceMap<K,V>
-
put
-
remove
-
putAll
-
merge
Description copied from interface:CacheWhen this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate
Externalizeror beSerializableitself.For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
-
merge
-
merge
-
forEach
-
clear
@ManagedOperation(description="Clears the cache", displayName="Clears the cache", name="clear") public void clear()Description copied from interface:CacheRemoves all mappings from the cache. Note: This should never be invoked in production unless you can guarantee no other invocations are ran concurrently. If the cache is transactional, it will not interact with the transaction. -
keySet
Description copied from interface:CacheReturns a set view of the keys contained in this cache and cache loader across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing set is just returned. Invocation on the set itself is when the various operations are ran.Unsupported Operations
Care should be taken when invokingSet.toArray(),Set.toArray(Object[]),Set.size(),Set.retainAll(Collection)andSet.iterator()methods as they will traverse the entire contents of the cluster including a configuredCacheLoaderand remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryErrordue to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operationsSupported Flags
Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets. If there are performance concerns then theFlag.SKIP_CACHE_LOADflag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to preventOutOfMemoryError) Also if you want the local contents only you can use theFlag.CACHE_MODE_LOCALflag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOADis also configured.Iterator Use
This class implements theCloseableIteratorSetinterface which creates aCloseableIteratorinstead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.Unsupported Operations
Due to not being able to add null values the following methods are not supported and will throwUnsupportedOperationExceptionif invoked.Set.add(Object)Set.addAll(java.util.Collection) -
entrySet
Description copied from interface:CacheReturns a set view of the mappings contained in this cache and cache loader across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing set is just returned. Invocation on the set itself is when the various operations are ran. Care should be taken when invokingSet.toArray(),Set.toArray(Object[]),Set.size(),Set.retainAll(Collection)andSet.iterator()methods as they will traverse the entire contents of the cluster including a configuredCacheLoaderand remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryErrordue to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operations *Supported Flags
Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets. If there are performance concerns then theFlag.SKIP_CACHE_LOADflag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to preventOutOfMemoryError) Also if you want the local contents only you can use theFlag.CACHE_MODE_LOCALflag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOADis also configured.Modifying or Adding Entries
An entry's value is supported to be modified by using theMap.Entry.setValue(Object)and it will update the cache as well. Also this backing set does allow addition of a new Map.Entry(s) via theSet.add(Object)orSet.addAll(java.util.Collection)methods.Iterator Use
This class implements theCloseableIteratorSetinterface which creates aCloseableIteratorinstead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly. -
values
Description copied from interface:CacheReturns a collection view of the values contained in this cache across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing collection is just returned. Invocation on the collection itself is when the various operations are ran. Care should be taken when invokingCollection.toArray(),Collection.toArray(Object[]),Collection.size(),Collection.retainAll(Collection)andCollection.iterator()methods as they will traverse the entire contents of the cluster including a configuredCacheLoaderand remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryErrordue to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operations *Supported Flags
Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets. If there are performance concerns then theFlag.SKIP_CACHE_LOADflag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to preventOutOfMemoryError) Also if you want the local contents only you can use theFlag.CACHE_MODE_LOCALflag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOADis also configured.Iterator Use
This class implements the
CloseableIteratorCollectioninterface which creates aCloseableIteratorinstead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.The iterator retrieved using
CloseableIteratorCollection.iterator()supports the remove method, however the iterator retrieved fromCacheStream.iterator()will not support remove.Unsupported Operations
Due to not being able to add null values the following methods are not supported and will throwUnsupportedOperationExceptionif invoked.Set.add(Object)Set.addAll(java.util.Collection) -
start
@ManagedOperation(description="Starts the cache.", displayName="Starts cache.") public void start()- Specified by:
startin interfaceorg.infinispan.commons.api.Lifecycle
-
stop
@ManagedOperation(description="Stops the cache.", displayName="Stops cache.") public void stop()Description copied from interface:CacheStops a cache. If the cache is clustered, this only stops the cache on the node where it is being invoked. If you need to stop the cache across a cluster, use theCache.shutdown()method. -
shutdown
@ManagedOperation(description="Shuts down the cache across the cluster", displayName="Clustered cache shutdown") public void shutdown()Description copied from interface:CachePerforms a controlled, clustered shutdown of the cache. When invoked, the following operations are performed:- rebalancing for the cache is disabled
- in-memory data is flushed/passivated to any persistent stores
- state is persisted to the location defined in
GlobalStateConfigurationBuilder.persistentLocation(String)
Cache.stop()only in clustered modes, and only whenGlobalStateConfiguration.enabled()is true, otherwise it just behaves likeCache.stop(). -
addListener
Description copied from interface:ListenableAdds a listener to the component. Typically, listeners would need to be annotated withListenerand further to that, contain methods annotated appropriately, otherwise the listener will not be registered. See theListenerannotation for more information.- Specified by:
addListenerin interfaceListenable- Parameters:
listener- listener to add, must not be null
-
addListenerAsync
Description copied from interface:ListenableAsynchronous version ofListenable.addListener(Object)- Specified by:
addListenerAsyncin interfaceListenable- Parameters:
listener- listener to add, must not be null- Returns:
- CompletionStage that when complete the listener is fully installed
-
addListener
public <C> void addListener(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter) Description copied from interface:FilteringListenableRegisters a listener that will be notified on events that pass the filter condition. The value presented in the notifications will be first converted using the provided converter if there is one.Some implementations may provide optimizations when a
CacheEventFilterConverteris provided as both arguments to the filter and converter arguments. Note the provided object must have reference equality ie. (==) to be recognized. This allows for the filter and conversion step to take place in the same method call reducing possible overhead.- Specified by:
addListenerin interfaceFilteringListenable<K,V> - Type Parameters:
C- The type of the resultant value after being converted- Parameters:
listener- The listener to callback upon event notifications. Must not be null.filter- The filter to see if the notification should be sent to the listener. Can be null.converter- The converter to apply to the entry before being sent to the listener. Can be null.
-
addListenerAsync
public <C> CompletionStage<Void> addListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter) Description copied from interface:FilteringListenableAsynchronous version ofFilteringListenable.addListener(Object, CacheEventFilter, CacheEventConverter)- Specified by:
addListenerAsyncin interfaceFilteringListenable<K,V> - Parameters:
listener- listener to add, must not be null- Returns:
- CompletionStage that when complete the listener is fully installed
-
removeListener
Description copied from interface:ListenableRemoves a listener from the component.- Specified by:
removeListenerin interfaceListenable- Parameters:
listener- listener to remove. Must not be null.
-
removeListenerAsync
Description copied from interface:ListenableAsynchronous version ofListenable.removeListener(Object)- Specified by:
removeListenerAsyncin interfaceListenable- Parameters:
listener- listener to remove, must not be null- Returns:
- CompletionStage that when complete the listener is fully removed
-
getListeners
Deprecated.- Specified by:
getListenersin interfaceListenable- Returns:
- a set of all listeners registered on this component.
-
addFilteredListener
public <C> void addFilteredListener(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Description copied from interface:FilteringListenableRegisters a listener limiting the cache-entry specific events only to annotations that are passed in as parameter. For example, if the listener passed in contains callbacks forCacheEntryCreatedandCacheEntryModified, and filtered annotations contains onlyCacheEntryCreated, then the listener will be registered only forCacheEntryCreatedcallbacks. Callback filtering only applies toCacheEntryCreated,CacheEntryModified,CacheEntryRemovedandCacheEntryExpiredannotations. If the listener contains other annotations, these are preserved. This methods enables dynamic registration of listener interests at runtime without the need to create several different listener classes.- Specified by:
addFilteredListenerin interfaceFilteringListenable<K,V> - Type Parameters:
C- The type of the resultant value after being converted- Parameters:
listener- The listener to callback upon event notifications. Must not be null.filter- The filter to see if the notification should be sent to the listener. Can be null.converter- The converter to apply to the entry before being sent to the listener. Can be null.filterAnnotations- cache-entry annotations to allow listener to be registered on. Must not be null.
-
addFilteredListenerAsync
public <C> CompletionStage<Void> addFilteredListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Description copied from interface:FilteringListenableAsynchronous version ofFilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)- Specified by:
addFilteredListenerAsyncin interfaceFilteringListenable<K,V>
-
addStorageFormatFilteredListener
public <C> void addStorageFormatFilteredListener(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Description copied from interface:FilteringListenableSame asFilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set), but assumes the filter and/or the converter will be done in the same data format as it's stored in the cache.- Specified by:
addStorageFormatFilteredListenerin interfaceFilteringListenable<K,V>
-
addStorageFormatFilteredListenerAsync
public <C> CompletionStage<Void> addStorageFormatFilteredListenerAsync(Object listener, CacheEventFilter<? super K, ? super V> filter, CacheEventConverter<? super K, ? super V, C> converter, Set<Class<? extends Annotation>> filterAnnotations) Description copied from interface:FilteringListenableAsynchronous version ofFilteringListenable.addStorageFormatFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)- Specified by:
addStorageFormatFilteredListenerAsyncin interfaceFilteringListenable<K,V>
-
getAsync
-
getAllAsync
-
getConfigurationAsProperties
@ManagedAttribute(description="Returns the cache configuration in form of properties", displayName="Cache configuration properties", dataType=TRAIT) public Properties getConfigurationAsProperties() -
toString
-
getDelegate
-
unwrapCache
Fully unwraps a given cache returning the base cache. Will unwrap all AbstractDelegatingCache wrappers.- Type Parameters:
K-V-- Parameters:
cache-- Returns:
-