Class AbstractDelegatingCache<K,V>
- All Implemented Interfaces:
ConcurrentMap<K,
,V> Map<K,
,V> Cache<K,
,V> InternalCache<K,
,V> AsyncCache<K,
,V> BasicCache<K,
,V> BatchingCache
,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> void
addFilteredListener
(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)
void
addListener
(Object listener) Adds a listener to the component.<C> void
addListener
(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> void
addStorageFormatFilteredListener
(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) void
clear()
Removes all mappings from the cache.Asynchronous version ofMap.clear()
.compute
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan parameters.compute
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.computeAsync
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) Asynchronous version ofConcurrentMap.compute(Object, BiFunction)
.computeAsync
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit)
.computeAsync
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)
.computeIfAbsent
(K key, Function<? super K, ? extends V> mappingFunction) computeIfAbsent
(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) An overloaded form ofConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan parameters.computeIfAbsent
(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan and maxIdleTime parameters.computeIfAbsentAsync
(K key, Function<? super K, ? extends V> mappingFunction) Asynchronous version ofConcurrentMap.computeIfAbsent(Object, Function)
.computeIfAbsentAsync
(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) Asynchronous version ofBasicCache.computeIfAbsent(Object, Function, long, TimeUnit)
.computeIfAbsentAsync
(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Asynchronous version ofBasicCache.computeIfAbsent(Object, Function, long, TimeUnit, long, TimeUnit)
.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) An overloaded form ofConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan parameters.computeIfPresent
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.computeIfPresentAsync
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) Asynchronous version ofConcurrentMap.computeIfPresent(Object, BiFunction)
.computeIfPresentAsync
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Asynchronous version ofBasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit)
.computeIfPresentAsync
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Asynchronous version ofBasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit, long, TimeUnit)
.boolean
containsKey
(Object key) boolean
containsValue
(Object value) void
endBatch
(boolean successful) Completes a batch if one has been started usingBatchingCache.startBatch()
.entrySet()
Returns a set view of the mappings contained in this cache and cache loader across the entire cluster.void
Evicts an entry from the memory of the cache.void
forEach
(BiConsumer<? super K, ? super V> action) getAllAsync
(Set<?> keys) TODO This should be in AdvancedCache with getAllAsynchronous version ofMap.get(Object)
that allows user code to retrieve the value associated with a key at a later stage, hence allowing multiple parallel get requests to be sent.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.getName()
Retrieves the name of the cachegetOrDefault
(Object key, V defaultValue) Retrieves the version of Infinispanboolean
isEmpty()
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) An overloaded form ofConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.merge
(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.mergeAsync
(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) Asynchronous version ofConcurrentMap.merge(Object, Object, BiFunction)
.mergeAsync
(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Asynchronous version ofBasicCache.merge(Object, Object, BiFunction, long, TimeUnit)
.mergeAsync
(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Asynchronous version ofBasicCache.merge(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)
.If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently as possible (i.e.An overloaded form ofBasicCache.put(Object, Object)
, which takes in lifespan parameters.put
(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofBasicCache.put(Object, Object)
, which takes in lifespan parameters.void
void
An overloaded form ofMap.putAll(Map)
, which takes in lifespan parameters.void
putAll
(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofMap.putAll(Map)
, which takes in lifespan parameters.putAllAsync
(Map<? extends K, ? extends V> data) Asynchronous version ofMap.putAll(Map)
.putAllAsync
(Map<? extends K, ? extends V> data, long lifespan, TimeUnit unit) Asynchronous version ofBasicCache.putAll(Map, long, TimeUnit)
.putAllAsync
(Map<? extends K, ? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Asynchronous version ofBasicCache.putAll(Map, long, TimeUnit, long, TimeUnit)
.Asynchronous version ofBasicCache.put(Object, Object)
.Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit)
.Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit, long, TimeUnit)
.void
putForExternalRead
(K key, V value) Under special operating behavior, associates the value with the specified key.void
putForExternalRead
(K key, V value, long lifespan, TimeUnit unit) An overloaded form ofCache.putForExternalRead(K, V)
, which takes in lifespan parameters.void
putForExternalRead
(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) An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.putIfAbsent
(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.putIfAbsentAsync
(K key, V value) Asynchronous version ofConcurrentMap.putIfAbsent(Object, Object)
.putIfAbsentAsync
(K key, V value, long lifespan, TimeUnit unit) Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit)
.putIfAbsentAsync
(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
.<T> Query
<T> If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently as possible (i.e.boolean
removeAsync
(Object key) Asynchronous version ofBasicCache.remove(Object)
.removeAsync
(Object key, Object value) Asynchronous version ofConcurrentMap.remove(Object, Object)
.void
removeListener
(Object listener) Removes a listener from the component.removeListenerAsync
(Object listener) Asynchronous version ofListenable.removeListener(Object)
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.replace
(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.boolean
boolean
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.boolean
replace
(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.void
replaceAll
(BiFunction<? super K, ? super V, ? extends V> function) replaceAsync
(K key, V value) Asynchronous version ofConcurrentMap.replace(Object, Object)
.replaceAsync
(K key, V value, long lifespan, TimeUnit unit) Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit)
.replaceAsync
(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit, long, TimeUnit)
.replaceAsync
(K key, V oldValue, V newValue) Asynchronous version ofConcurrentMap.replace(Object, Object, Object)
.replaceAsync
(K key, V oldValue, V newValue, long lifespan, TimeUnit unit) Asynchronous version ofBasicCache.replace(Object, Object, Object, long, TimeUnit)
.replaceAsync
(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Asynchronous version ofBasicCache.replace(Object, Object, Object, long, TimeUnit, long, TimeUnit)
.void
shutdown()
Performs a controlled, clustered shutdown of the cache.int
size()
Returns a count of all elements in this cache and cache loader across the entire cluster.Asynchronous version ofMap.size()
.void
start()
Invoked on component startboolean
Starts a batch.void
stop()
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, wait
Methods inherited from interface org.infinispan.commons.api.AsyncCache
containsKeyAsync
Methods 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
-
getComponentRegistry
- Specified by:
getComponentRegistry
in interfaceInternalCache<K,
V>
-
putForExternalRead
Description copied from interface:Cache
Under 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:
putForExternalRead
in 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:Cache
An overloaded form ofCache.putForExternalRead(K, V)
, which takes in lifespan parameters.- Specified by:
putForExternalRead
in 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:Cache
An overloaded form ofCache.putForExternalRead(K, V)
, which takes in lifespan parameters.- Specified by:
putForExternalRead
in 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:Cache
Evicts 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:
getCacheConfiguration
in interfaceCache<K,
V>
-
startBatch
public boolean startBatch()Description copied from interface:BatchingCache
Starts a batch. All operations on the current client thread are performed as a part of this batch, with locks held for the duration of the batch and any remote calls delayed till the end of the batch.- Specified by:
startBatch
in interfaceBatchingCache
- Returns:
- true if a batch was successfully started; false if one was available and already running.
-
endBatch
public void endBatch(boolean successful) Description copied from interface:BatchingCache
Completes a batch if one has been started usingBatchingCache.startBatch()
. If no batch has been started, this is a no-op.- Specified by:
endBatch
in interfaceBatchingCache
- Parameters:
successful
- if true, the batch completes, otherwise the batch is aborted and changes are not committed.
-
getName
Description copied from interface:BasicCache
Retrieves the name of the cache- Specified by:
getName
in interfaceBasicCache<K,
V> - Returns:
- the name of the cache
-
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()Description copied from interface:BasicCache
Retrieves the version of Infinispan- Specified by:
getVersion
in interfaceBasicCache<K,
V> - Returns:
- a version string
-
getCacheManager
Description copied from interface:Cache
Retrieves the cache manager responsible for creating this cache instance.- Specified by:
getCacheManager
in interfaceCache<K,
V> - Returns:
- a cache manager
-
put
Description copied from interface:BasicCache
An overloaded form ofBasicCache.put(Object, Object)
, which takes in lifespan parameters.- Specified by:
put
in interfaceBasicCache<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- Returns:
- the value being replaced, or null if nothing is being replaced.
-
putIfAbsent
Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.- Specified by:
putIfAbsent
in interfaceBasicCache<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- Returns:
- the value being replaced, or null if nothing is being replaced.
-
putAll
Description copied from interface:BasicCache
An overloaded form ofMap.putAll(Map)
, which takes in lifespan parameters. Note that the lifespan is applied to all mappings in the map passed in.- Specified by:
putAll
in interfaceBasicCache<K,
V> - Parameters:
map
- map containing mappings to enterlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespan
-
replace
Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.- Specified by:
replace
in interfaceBasicCache<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- Returns:
- the value being replaced, or null if nothing is being replaced.
-
replace
Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.- Specified by:
replace
in interfaceBasicCache<K,
V> - Parameters:
key
- key to useoldValue
- value to replacevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespan- Returns:
- true if the value was replaced, false otherwise
-
put
public V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofBasicCache.put(Object, Object)
, which takes in lifespan parameters.- Specified by:
put
in interfaceBasicCache<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 lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the value being replaced, or null if nothing is being replaced.
-
putIfAbsent
public V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.- Specified by:
putIfAbsent
in interfaceBasicCache<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 lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the value being replaced, or null if nothing is being replaced.
-
putAll
public void putAll(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofMap.putAll(Map)
, which takes in lifespan parameters. Note that the lifespan is applied to all mappings in the map passed in.- Specified by:
putAll
in interfaceBasicCache<K,
V> - Parameters:
map
- map containing mappings to enterlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time
-
replace
public V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.- Specified by:
replace
in interfaceBasicCache<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 lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the value being replaced, or null if nothing is being replaced.
-
replace
public boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.- Specified by:
replace
in interfaceBasicCache<K,
V> - Parameters:
key
- key to useoldValue
- value to replacevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- true if the value was replaced, false otherwise
-
replaceAll
- Specified by:
replaceAll
in interfaceConcurrentMap<K,
V> - Specified by:
replaceAll
in interfaceMap<K,
V>
-
putAsync
Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.put(Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to usevalue
- value to store- Returns:
- a future containing the old value replaced.
-
putAsync
Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespan- Returns:
- a future containing the old value replaced
-
putAsync
public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- 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- Returns:
- a future containing the old value replaced
-
putAllAsync
Description copied from interface:AsyncCache
Asynchronous version ofMap.putAll(Map)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAllAsync
in interfaceAsyncCache<K,
V> - Parameters:
data
- to store- Returns:
- a future containing a void return type
-
putAllAsync
public CompletableFuture<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit unit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.putAll(Map, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAllAsync
in interfaceAsyncCache<K,
V> - Parameters:
data
- to storelifespan
- lifespan of entryunit
- time unit for lifespan- Returns:
- a future containing a void return type
-
putAllAsync
public CompletableFuture<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.putAll(Map, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAllAsync
in interfaceAsyncCache<K,
V> - Parameters:
data
- to storelifespan
- lifespan of entrylifespanUnit
- 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- Returns:
- a future containing a void return type
-
clearAsync
Description copied from interface:AsyncCache
Asynchronous version ofMap.clear()
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
clearAsync
in interfaceAsyncCache<K,
V> - Returns:
- a future containing a void return type
-
putIfAbsentAsync
Description copied from interface:AsyncCache
Asynchronous version ofConcurrentMap.putIfAbsent(Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putIfAbsentAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to usevalue
- value to store- Returns:
- a future containing the old value replaced.
-
putIfAbsentAsync
Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putIfAbsentAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespan- Returns:
- a future containing the old value replaced
-
putIfAbsentAsync
public CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putIfAbsentAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- 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- Returns:
- a future containing the old value replaced
-
removeAsync
Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.remove(Object)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
removeAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to remove- Returns:
- a future containing the value removed
-
removeAsync
Description copied from interface:AsyncCache
Asynchronous version ofConcurrentMap.remove(Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
removeAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to removevalue
- value to match on- Returns:
- a future containing a boolean, indicating whether the entry was removed or not
-
replaceAsync
Description copied from interface:AsyncCache
Asynchronous version ofConcurrentMap.replace(Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to removevalue
- value to store- Returns:
- a future containing the previous value overwritten
-
replaceAsync
Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to removevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespan- Returns:
- a future containing the previous value overwritten
-
replaceAsync
public CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to removevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- 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- Returns:
- a future containing the previous value overwritten
-
replaceAsync
Description copied from interface:AsyncCache
Asynchronous version ofConcurrentMap.replace(Object, Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to removeoldValue
- value to overwritenewValue
- value to store- Returns:
- a future containing a boolean, indicating whether the entry was replaced or not
-
replaceAsync
public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.replace(Object, Object, Object, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to removeoldValue
- value to overwritenewValue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespan- Returns:
- a future containing a boolean, indicating whether the entry was replaced or not
-
replaceAsync
public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.replace(Object, Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to removeoldValue
- value to overwritenewValue
- value to storelifespan
- lifespan of entrylifespanUnit
- 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- Returns:
- a future containing a boolean, indicating whether the entry was replaced or not
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) Description copied from interface:AsyncCache
Asynchronous version ofConcurrentMap.compute(Object, BiFunction)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsync
in interfaceAsyncCache<K,
V>
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsync
in interfaceAsyncCache<K,
V>
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsync
in interfaceAsyncCache<K,
V>
-
computeIfAbsentAsync
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction) Description copied from interface:AsyncCache
Asynchronous version ofConcurrentMap.computeIfAbsent(Object, Function)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfAbsentAsync
in interfaceAsyncCache<K,
V>
-
computeIfAbsentAsync
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.computeIfAbsent(Object, Function, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfAbsentAsync
in interfaceAsyncCache<K,
V>
-
computeIfAbsentAsync
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.computeIfAbsent(Object, Function, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfAbsentAsync
in interfaceAsyncCache<K,
V>
-
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) Description copied from interface:AsyncCache
Asynchronous version ofConcurrentMap.computeIfPresent(Object, BiFunction)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfPresentAsync
in interfaceAsyncCache<K,
V>
-
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfPresentAsync
in interfaceAsyncCache<K,
V>
-
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfPresentAsync
in interfaceAsyncCache<K,
V>
-
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) Description copied from interface:AsyncCache
Asynchronous version ofConcurrentMap.merge(Object, Object, BiFunction)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
mergeAsync
in interfaceAsyncCache<K,
V>
-
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.merge(Object, Object, BiFunction, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
mergeAsync
in interfaceAsyncCache<K,
V>
-
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) Description copied from interface:AsyncCache
Asynchronous version ofBasicCache.merge(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
mergeAsync
in interfaceAsyncCache<K,
V>
-
getAdvancedCache
- Specified by:
getAdvancedCache
in 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:
putIfAbsent
in interfaceConcurrentMap<K,
V> - Specified by:
putIfAbsent
in interfaceMap<K,
V>
-
remove
-
replace
-
replace
-
size
public int size()Description copied from interface:Cache
Returns 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_LOAD
flag 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_LOCAL
flag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOAD
is 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_COMMITTED
behavior 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_READ
This 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
Description copied from interface:AsyncCache
Asynchronous version ofMap.size()
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
sizeAsync
in interfaceAsyncCache<K,
V> - Returns:
- a future containing the count of the cache
-
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
compute
Description copied from interface:Cache
When 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
Externalizer
or beSerializable
itself.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
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan parameters.- Specified by:
compute
in interfaceBasicCache<K,
V> - Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the computed value that was stored under key
-
compute
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.- Specified by:
compute
in interfaceBasicCache<K,
V> - Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the computed value that was stored under key
-
computeIfPresent
Description copied from interface:Cache
When 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
Externalizer
or beSerializable
itself.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:
computeIfPresent
in interfaceCache<K,
V> - Specified by:
computeIfPresent
in interfaceConcurrentMap<K,
V> - Specified by:
computeIfPresent
in interfaceMap<K,
V>
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan parameters.- Specified by:
computeIfPresent
in interfaceBasicCache<K,
V> - Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under key, if such existslifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the computed value that was stored under key
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.- Specified by:
computeIfPresent
in interfaceBasicCache<K,
V> - Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under key, if such existslifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the computed value that was stored under key
-
computeIfAbsent
Description copied from interface:Cache
When 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
Externalizer
or beSerializable
itself.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:
computeIfAbsent
in interfaceCache<K,
V> - Specified by:
computeIfAbsent
in interfaceConcurrentMap<K,
V> - Specified by:
computeIfAbsent
in interfaceMap<K,
V>
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan parameters.- Specified by:
computeIfAbsent
in interfaceBasicCache<K,
V> - Parameters:
key
- key to usemappingFunction
- function to use to compute and store the value under key, if the key is absentlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the computed value that was stored under key
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan and maxIdleTime parameters.- Specified by:
computeIfAbsent
in interfaceBasicCache<K,
V> - Parameters:
key
- key to usemappingFunction
- function to use to compute and store the value under key, if the key is absentlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the computed value that was stored under key
-
get
-
getOrDefault
- Specified by:
getOrDefault
in interfaceConcurrentMap<K,
V> - Specified by:
getOrDefault
in interfaceMap<K,
V>
-
put
Description copied from interface:BasicCache
If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently as possible (i.e. avoiding needless remote or network calls). -
remove
Description copied from interface:BasicCache
If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently as possible (i.e. avoiding needless remote or network calls). -
putAll
-
merge
Description copied from interface:Cache
When 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
Externalizer
or beSerializable
itself.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
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.- Specified by:
merge
in interfaceBasicCache<K,
V> - Parameters:
key
- key to usevalue
- new value to merge with existing valueremappingFunction
- function to use to merge new and existing values into a merged value to store under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the merged value that was stored under key
-
merge
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) Description copied from interface:BasicCache
An overloaded form ofConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.- Specified by:
merge
in interfaceBasicCache<K,
V> - Parameters:
key
- key to usevalue
- new value to merge with existing valueremappingFunction
- function to use to merge new and existing values into a merged value to store under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the merged value that was stored under key
-
forEach
-
clear
@ManagedOperation(description="Clears the cache", displayName="Clears the cache", name="clear") public void clear()Description copied from interface:Cache
Removes 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:Cache
Returns 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 configuredCacheLoader
and remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryError
due 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_LOAD
flag 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_LOCAL
flag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOAD
is also configured.Iterator Use
This class implements theCloseableIteratorSet
interface which creates aCloseableIterator
instead 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 throwUnsupportedOperationException
if invoked.Set.add(Object)
Set.addAll(java.util.Collection)
-
entrySet
Description copied from interface:Cache
Returns 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 configuredCacheLoader
and remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryError
due 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_LOAD
flag 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_LOCAL
flag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOAD
is 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 theCloseableIteratorSet
interface which creates aCloseableIterator
instead 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:Cache
Returns 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 configuredCacheLoader
and remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryError
due 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_LOAD
flag 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_LOCAL
flag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOAD
is also configured.Iterator Use
This class implements the
CloseableIteratorCollection
interface which creates aCloseableIterator
instead 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 throwUnsupportedOperationException
if invoked.Set.add(Object)
Set.addAll(java.util.Collection)
-
start
@ManagedOperation(description="Starts the cache.", displayName="Starts cache.") public void start()Description copied from interface:Lifecycle
Invoked on component start -
stop
@ManagedOperation(description="Stops the cache.", displayName="Stops cache.") public void stop()Description copied from interface:Cache
Stops 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:Cache
Performs 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:Listenable
Adds a listener to the component. Typically, listeners would need to be annotated withListener
and further to that, contain methods annotated appropriately, otherwise the listener will not be registered. See theListener
annotation for more information.- Specified by:
addListener
in interfaceListenable
- Parameters:
listener
- listener to add, must not be null
-
addListenerAsync
Description copied from interface:Listenable
Asynchronous version ofListenable.addListener(Object)
- Specified by:
addListenerAsync
in 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:FilteringListenable
Registers 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
CacheEventFilterConverter
is 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:
addListener
in 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:FilteringListenable
Asynchronous version ofFilteringListenable.addListener(Object, CacheEventFilter, CacheEventConverter)
- Specified by:
addListenerAsync
in interfaceFilteringListenable<K,
V> - Type Parameters:
C
-- Parameters:
listener
- listener to add, must not be nullfilter
-converter
-- Returns:
- CompletionStage that when complete the listener is fully installed
-
removeListener
Description copied from interface:Listenable
Removes a listener from the component.- Specified by:
removeListener
in interfaceListenable
- Parameters:
listener
- listener to remove. Must not be null.
-
removeListenerAsync
Description copied from interface:Listenable
Asynchronous version ofListenable.removeListener(Object)
- Specified by:
removeListenerAsync
in interfaceListenable
- Parameters:
listener
- listener to remove, must not be null- Returns:
- CompletionStage that when complete the listener is fully removed
-
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:FilteringListenable
Registers 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 forCacheEntryCreated
andCacheEntryModified
, and filtered annotations contains onlyCacheEntryCreated
, then the listener will be registered only forCacheEntryCreated
callbacks. Callback filtering only applies toCacheEntryCreated
,CacheEntryModified
,CacheEntryRemoved
andCacheEntryExpired
annotations. 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:
addFilteredListener
in 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:FilteringListenable
Asynchronous version ofFilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)
- Specified by:
addFilteredListenerAsync
in 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:FilteringListenable
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.- Specified by:
addStorageFormatFilteredListener
in 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:FilteringListenable
Asynchronous version ofFilteringListenable.addStorageFormatFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)
- Specified by:
addStorageFormatFilteredListenerAsync
in interfaceFilteringListenable<K,
V>
-
getAsync
Description copied from interface:AsyncCache
Asynchronous version ofMap.get(Object)
that allows user code to retrieve the value associated with a key at a later stage, hence allowing multiple parallel get requests to be sent. Normally, when this method detects that the value is likely to be retrieved from from a remote entity, it will span a different thread in order to allow the asynchronous get call to return immediately. If the call will definitely resolve locally, for example when the cache is configured with LOCAL mode and no stores are configured, the get asynchronous call will act sequentially and will have no different toMap.get(Object)
.- Specified by:
getAsync
in interfaceAsyncCache<K,
V> - Parameters:
key
- key to retrieve- Returns:
- a future that can be used to retrieve value associated with the
key when this is available. The actual value returned by the future
follows the same rules as
Map.get(Object)
-
getAllAsync
Description copied from interface:AsyncCache
TODO This should be in AdvancedCache with getAll- Specified by:
getAllAsync
in interfaceAsyncCache<K,
V>
-
query
- Specified by:
query
in interfaceBasicCache<K,
V>
-
continuousQuery
- Specified by:
continuousQuery
in interfaceBasicCache<K,
V> - Returns:
- a continuous query service usable with the current cache context
-
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:
-