Interface Cache<K,V> 
- All Superinterfaces:
- AsyncCache<K,,- V> - BasicCache<K,,- V> - BatchingCache,- ConcurrentMap<K,,- V> - FilteringListenable<K,,- V> - Lifecycle,- Listenable,- Map<K,- V> 
- All Known Subinterfaces:
- AdvancedCache<K,,- V> - SecureCache<K,- V> 
- All Known Implementing Classes:
- AbstractDelegatingAdvancedCache,- AbstractDelegatingCache,- AliasCache,- CacheImpl,- DecoratedCache,- EncoderCache,- SecureCacheImpl,- SimpleCacheImpl,- StatsCollectingCache
- JTA transaction compatibility
- Eviction support for evicting entries from memory to prevent OutOfMemoryErrors
- Persisting entries to a CacheLoader, either when they are evicted as an overflow, or all the time, to maintain persistent copies that would withstand server failure or restarts.
ConcurrentMap and implements all methods accordingly.  Methods like
 keySet(), values() and entrySet() produce backing collections in that updates done to them
 also update the original Cache instance.  Certain methods on these maps can be expensive however (prohibitively so
 when using a distributed cache).  The size() and Map.containsValue(Object) methods upon invocation can
 also be expensive just as well.  The reason these methods are expensive are that they take into account entries
 stored in a configured CacheLoader and remote entries when using a distributed cache.
 Frequent use of these methods is not recommended if used in this manner.  These aforementioned methods do take into
 account in-flight transactions, however key/value pairs read in using an iterator will not be placed into the transactional
 context to prevent OutOfMemoryErrors.  Please note all of these methods behavior can be controlled using
 a Flag to disable certain things such as taking into account the loader.  Please see
 each method on this interface for more details.
 
 Also, like many ConcurrentMap implementations, Cache does not support the use of null keys or
 values.
 
 Asynchronous operations
Cache also supports the use of "async" remote operations. Note that these methods only really make sense if you are using a clustered cache. I.e., when used in LOCAL mode, these "async" operations offer no benefit whatsoever. These methods, such asAsyncCache.putAsync(Object, Object) offer the best of both worlds
 between a fully synchronous and a fully asynchronous cache in that a CompletableFuture is returned.  The
 CompletableFuture can then be ignored or thrown away for typical asynchronous behaviour, or queried for
 synchronous behaviour, which would block until any remote calls complete.  Note that all remote calls are, as far as
 the transport is concerned, synchronous.  This allows you the guarantees that remote calls succeed, while not
 blocking your application thread unnecessarily.  For example, usage such as the following could benefit from the
 async operations:
 
   CompletableFuture f1 = cache.putAsync("key1", "value1");
   CompletableFuture f2 = cache.putAsync("key2", "value2");
   CompletableFuture f3 = cache.putAsync("key3", "value3");
   f1.get();
   f2.get();
   f3.get();
 
 The net result is behavior similar to synchronous RPC calls in that at the end, you have guarantees that all calls
 completed successfully, but you have the added benefit that the three calls could happen in parallel.  This is
 especially advantageous if the cache uses distribution and the three keys map to different cache instances in the
 cluster.
 
 Also, the use of async operations when within a transaction return your local value only, as expected.  A
 CompletableFuture is still returned though for API consistency.
 
 Constructing a Cache
An instance of the Cache is usually obtained by using aCacheContainer.
 CacheManager cm = new DefaultCacheManager(); // optionally pass in a default configuration Cache c = cm.getCache();See the
CacheContainer interface for more details on providing specific configurations, using multiple caches
 in the same JVM, etc.
 
 Please see the Infinispan documentation and/or the 5 Minute Usage Tutorial for more details.
 - Since:
- 4.0
- Author:
- Mircea.Markus@jboss.com, Manik Surtani, Galder Zamarreño
- See Also:
- 
Nested Class Summary
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Removes all mappings from the cache.default VOverloadedcompute(Object, BiFunction)with InfinispanSerializableBiFunction.default Vcompute(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedBasicCache.compute(Object, BiFunction, long, TimeUnit)with InfinispanSerializableBiFunction.default Vcompute(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedBasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)with InfinispanSerializableBiFunction.default CompletableFuture<V> computeAsync(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction) OverloadedAsyncCache.computeAsync(Object, BiFunction)with InfinispanSerializableBiFunction.default CompletableFuture<V> computeAsync(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedAsyncCache.computeAsync(Object, BiFunction, long, TimeUnit)with InfinispanSerializableBiFunction.default CompletableFuture<V> computeAsync(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedAsyncCache.computeAsync(Object, BiFunction, long, TimeUnit, long, TimeUnit)with InfinispanSerializableBiFunction.computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) default VcomputeIfAbsent(K key, SerializableFunction<? super K, ? extends V> mappingFunction) OverloadedcomputeIfAbsent(Object, Function)with InfinispanSerializableFunction.default VcomputeIfAbsent(K key, SerializableFunction<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedBasicCache.computeIfAbsent(Object, Function, long, TimeUnit)with InfinispanSerializableFunction.default VcomputeIfAbsent(K key, SerializableFunction<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedBasicCache.computeIfAbsent(Object, Function, long, TimeUnit, long, TimeUnit)with InfinispanSerializableFunction.default CompletableFuture<V> computeIfAbsentAsync(K key, SerializableFunction<? super K, ? extends V> mappingFunction) OverloadedAsyncCache.computeIfAbsentAsync(Object, Function)with InfinispanSerializableFunction.default CompletableFuture<V> computeIfAbsentAsync(K key, SerializableFunction<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedAsyncCache.computeIfAbsentAsync(Object, Function, long, TimeUnit)with InfinispanSerializableFunction.default CompletableFuture<V> computeIfAbsentAsync(K key, SerializableFunction<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedAsyncCache.computeIfAbsentAsync(Object, Function, long, TimeUnit, long, TimeUnit)with InfinispanSerializableFunction.computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) default VcomputeIfPresent(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction) OverloadedcomputeIfPresent(Object, BiFunction)with InfinispanSerializableBiFunctionThe compiler will pick this overload for lambda parameters, making themSerializabledefault CompletableFuture<V> computeIfPresentAsync(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction) OverloadedAsyncCache.computeIfPresentAsync(Object, BiFunction)with InfinispanSerializableBiFunctionThe compiler will pick this overload for lambda parameters, making themSerializableentrySet()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.Retrieves the cache manager responsible for creating this cache instance.keySet()Returns a set view of the keys contained in this cache and cache loader across the entire cluster.default VOverloadedmerge(Object, Object, BiFunction)with InfinispanSerializableBiFunction.default Vmerge(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedBasicCache.merge(Object, Object, BiFunction, long, TimeUnit)with InfinispanSerializableBiFunction.default Vmerge(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedBasicCache.merge(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)with InfinispanSerializableBiFunction.default CompletableFuture<V> mergeAsync(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction) OverloadedAsyncCache.mergeAsync(Object, Object, BiFunction)with InfinispanSerializableBiFunction.default CompletableFuture<V> mergeAsync(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedAsyncCache.mergeAsync(Object, Object, BiFunction, long, TimeUnit)with InfinispanSerializableBiFunction.default CompletableFuture<V> mergeAsync(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedAsyncCache.mergeAsync(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)with InfinispanSerializableBiFunction.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 ofputForExternalRead(K, V), which takes in lifespan parameters.voidputForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) An overloaded form ofputForExternalRead(K, V), which takes in lifespan parameters.default 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.voidstop()Stops a cache.values()Returns a collection view of the values contained in this cache across the entire cluster.Methods inherited from interface org.infinispan.commons.api.AsyncCacheclearAsync, computeAsync, computeAsync, computeAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresentAsync, computeIfPresentAsync, computeIfPresentAsync, containsKeyAsync, getAllAsync, getAsync, mergeAsync, mergeAsync, mergeAsync, putAllAsync, putAllAsync, putAllAsync, putAsync, putAsync, putAsync, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, sizeAsyncMethods inherited from interface org.infinispan.commons.api.BasicCachecompute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, continuousQuery, getName, getVersion, merge, merge, put, put, put, putAll, putAll, putIfAbsent, putIfAbsent, query, remove, replace, replace, replace, replaceMethods inherited from interface org.infinispan.commons.api.BatchingCacheendBatch, startBatchMethods inherited from interface java.util.concurrent.ConcurrentMapforEach, getOrDefault, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface org.infinispan.notifications.FilteringListenableaddFilteredListener, addFilteredListenerAsync, addListener, addListenerAsync, addStorageFormatFilteredListener, addStorageFormatFilteredListenerAsyncMethods inherited from interface org.infinispan.notifications.ListenableaddListener, addListenerAsync, removeListener, removeListenerAsyncMethods inherited from interface java.util.MapcontainsKey, containsValue, equals, get, hashCode, isEmpty, putAll
- 
Method Details- 
putForExternalReadUnder 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
 - Parameters:
- key- key with which the specified value is to be associated.
- value- value to be associated with the specified key.
- Throws:
- IllegalStateException- if- getStatus()would not return- ComponentStatus.RUNNING.
 
-  Only goes through if the
 key specified does not exist; no-op otherwise (similar to 
- 
putForExternalReadAn overloaded form ofputForExternalRead(K, V), which takes in lifespan parameters.- Parameters:
- key- key to use
- value- value to store
- lifespan- lifespan of the entry. Negative values are interpreted as unlimited lifespan.
- unit- unit of measurement for the lifespan
- Since:
- 7.0
 
- 
putForExternalReadvoid putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) An overloaded form ofputForExternalRead(K, V), which takes in lifespan parameters.- Parameters:
- key- key to use
- value- value to store
- lifespan- lifespan of the entry. Negative values are interpreted as unlimited lifespan.
- lifespanUnit- time unit for lifespan
- maxIdle- the maximum amount of time this key is allowed to be idle for before it is considered as expired
- maxIdleUnit- time unit for max idle time
- Since:
- 7.0
 
- 
evictEvicts 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.- Parameters:
- key- key to evict
 
- 
getCacheConfigurationConfiguration getCacheConfiguration()
- 
getCacheManagerEmbeddedCacheManager getCacheManager()Retrieves the cache manager responsible for creating this cache instance.- Returns:
- a cache manager
 
- 
getAdvancedCacheAdvancedCache<K,V> getAdvancedCache()
- 
getStatusComponentStatus getStatus()
- 
sizeint size()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_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.
- 
keySetReturns 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 OperationsCare 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 FlagsNote 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 UseThis 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 OperationsDue 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)
- 
valuesCacheCollection<V> values()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 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 FlagsNote 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 UseThis 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 OperationsDue 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)
- 
entrySetReturns 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 FlagsNote 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 EntriesAn 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 UseThis 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.
- 
clearvoid clear()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.
- 
stopvoid stop()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 theshutdown()method.
- 
shutdowndefault void shutdown()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)
 stop()only in clustered modes, and only whenGlobalStateConfiguration.enabled()is true, otherwise it just behaves likestop().
- 
computeIfAbsentWhen 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 interface- ConcurrentMap<K,- V> 
- Specified by:
- computeIfAbsentin interface- Map<K,- V> 
 
- 
computeIfAbsentOverloadedcomputeIfAbsent(Object, Function)with InfinispanSerializableFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- mappingFunction- , mapping function to be appliyed to the key
- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
 
- 
computeIfAbsentdefault V computeIfAbsent(K key, SerializableFunction<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedBasicCache.computeIfAbsent(Object, Function, long, TimeUnit)with InfinispanSerializableFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- mappingFunction- , mapping function to be appliyed to the key
- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
 
- 
computeIfAbsentdefault V computeIfAbsent(K key, SerializableFunction<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedBasicCache.computeIfAbsent(Object, Function, long, TimeUnit, long, TimeUnit)with InfinispanSerializableFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- mappingFunction- , mapping function to be appliyed to the key
- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
 
- 
computeIfAbsentAsyncdefault CompletableFuture<V> computeIfAbsentAsync(K key, SerializableFunction<? super K, ? extends V> mappingFunction) OverloadedAsyncCache.computeIfAbsentAsync(Object, Function)with InfinispanSerializableFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- mappingFunction- , mapping function to be appliyed to the key
- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
 
- 
computeIfAbsentAsyncdefault CompletableFuture<V> computeIfAbsentAsync(K key, SerializableFunction<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedAsyncCache.computeIfAbsentAsync(Object, Function, long, TimeUnit)with InfinispanSerializableFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- mappingFunction- , mapping function to be appliyed to the key
- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
 
- 
computeIfAbsentAsyncdefault CompletableFuture<V> computeIfAbsentAsync(K key, SerializableFunction<? super K, ? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedAsyncCache.computeIfAbsentAsync(Object, Function, long, TimeUnit, long, TimeUnit)with InfinispanSerializableFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- mappingFunction- , mapping function to be appliyed to the key
- Returns:
- the current (existing or computed) value associated with the specified key, or null if the computed value is null
 
- 
computeIfPresentWhen 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 interface- ConcurrentMap<K,- V> 
- Specified by:
- computeIfPresentin interface- Map<K,- V> 
 
- 
computeIfPresentdefault V computeIfPresent(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction) OverloadedcomputeIfPresent(Object, BiFunction)with InfinispanSerializableBiFunctionThe compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- remappingFunction- , mapping function to be appliyed to the key
- Returns:
- computed value or null if nothing is computed or computation result is null
 
- 
computeIfPresentAsyncdefault CompletableFuture<V> computeIfPresentAsync(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction) OverloadedAsyncCache.computeIfPresentAsync(Object, BiFunction)with InfinispanSerializableBiFunctionThe compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- remappingFunction- , mapping function to be appliyed to the key
- Returns:
- computed value or null if nothing is computed or computation result is null
 
- 
computeWhen 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. 
- 
computeOverloadedcompute(Object, BiFunction)with InfinispanSerializableBiFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- remappingFunction- , mapping function to be appliyed to the key
- Returns:
- computation result (can be null)
 
- 
computedefault V compute(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedBasicCache.compute(Object, BiFunction, long, TimeUnit)with InfinispanSerializableBiFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- remappingFunction- , mapping function to be appliyed to the key
- Returns:
- computation result (can be null)
 
- 
computedefault V compute(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedBasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)with InfinispanSerializableBiFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- remappingFunction- , mapping function to be appliyed to the key
- Returns:
- computation result (can be null)
 
- 
computeAsyncdefault CompletableFuture<V> computeAsync(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction) OverloadedAsyncCache.computeAsync(Object, BiFunction)with InfinispanSerializableBiFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- remappingFunction- , mapping function to be appliyed to the key
- Returns:
- computation result (can be null)
 
- 
computeAsyncdefault CompletableFuture<V> computeAsync(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedAsyncCache.computeAsync(Object, BiFunction, long, TimeUnit)with InfinispanSerializableBiFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- remappingFunction- , mapping function to be appliyed to the key
- Returns:
- computation result (can be null)
 
- 
computeAsyncdefault CompletableFuture<V> computeAsync(K key, SerializableBiFunction<? super K, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedAsyncCache.computeAsync(Object, BiFunction, long, TimeUnit, long, TimeUnit)with InfinispanSerializableBiFunction. The compiler will pick this overload for lambda parameters, making themSerializable- Parameters:
- key- , the key to be computed
- remappingFunction- , mapping function to be appliyed to the key
- Returns:
- computation result (can be null)
 
- 
mergeWhen 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. 
- 
mergedefault V merge(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction) Overloadedmerge(Object, Object, BiFunction)with InfinispanSerializableBiFunction.The compiler will pick this overload for lambda parameters, making them Serializable.- Parameters:
- key- key with which the resulting value is to be associated
- value- the non-null value to be merged with the existing value associated with the key or, if no existing value or a null value is associated with the key, to be associated with the key
- remappingFunction- the function to recompute a value if present
 
- 
mergedefault V merge(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedBasicCache.merge(Object, Object, BiFunction, long, TimeUnit)with InfinispanSerializableBiFunction.- Parameters:
- key- key to use
- value- new value to merge with existing value
- remappingFunction- function to use to merge new and existing values into a merged value to store under key
- lifespan- 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
- Since:
- 9.4
 
- 
mergedefault V merge(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedBasicCache.merge(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)with InfinispanSerializableBiFunction.- Parameters:
- key- key to use
- value- new value to merge with existing value
- remappingFunction- function to use to merge new and existing values into a merged value to store under key
- lifespan- lifespan of the entry. Negative values are interpreted as unlimited lifespan.
- lifespanUnit- time unit for lifespan
- maxIdleTime- the maximum amount of time this key is allowed to be idle for before it is considered as expired
- maxIdleTimeUnit- time unit for max idle time
- Returns:
- the merged value that was stored under key
- Since:
- 9.4
 
- 
mergeAsyncdefault CompletableFuture<V> mergeAsync(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction) OverloadedAsyncCache.mergeAsync(Object, Object, BiFunction)with InfinispanSerializableBiFunction.- Parameters:
- key- key to use
- value- new value to merge with existing value
- remappingFunction- function to use to merge new and existing values into a merged value to store under key
- Returns:
- the merged value that was stored under key
- Since:
- 10.0
 
- 
mergeAsyncdefault CompletableFuture<V> mergeAsync(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit) OverloadedAsyncCache.mergeAsync(Object, Object, BiFunction, long, TimeUnit)with InfinispanSerializableBiFunction.- Parameters:
- key- key to use
- value- new value to merge with existing value
- remappingFunction- function to use to merge new and existing values into a merged value to store under key
- lifespan- 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
- Since:
- 10.0
 
- 
mergeAsyncdefault CompletableFuture<V> mergeAsync(K key, V value, SerializableBiFunction<? super V, ? super V, ? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit) OverloadedAsyncCache.mergeAsync(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)with InfinispanSerializableBiFunction.- Parameters:
- key- key to use
- value- new value to merge with existing value
- remappingFunction- function to use to merge new and existing values into a merged value to store under key
- lifespan- lifespan of the entry. Negative values are interpreted as unlimited lifespan.
- lifespanUnit- time unit for lifespan
- maxIdleTime- the maximum amount of time this key is allowed to be idle for before it is considered as expired
- maxIdleTimeUnit- time unit for max idle time
- Returns:
- the merged value that was stored under key
- Since:
- 10.0
 
 
-