Class DecoratedCache<K,V>
- java.lang.Object
-
- org.infinispan.cache.impl.AbstractDelegatingCache<K,V>
-
- org.infinispan.cache.impl.AbstractDelegatingAdvancedCache<K,V>
-
- org.infinispan.cache.impl.DecoratedCache<K,V>
-
- All Implemented Interfaces:
ConcurrentMap<K,V>,Map<K,V>,AdvancedCache<K,V>,Cache<K,V>,org.infinispan.commons.api.AsyncCache<K,V>,org.infinispan.commons.api.BasicCache<K,V>,org.infinispan.commons.api.BatchingCache,org.infinispan.commons.api.Lifecycle,org.infinispan.commons.api.TransactionalCache,FilteringListenable<K,V>,Listenable
public class DecoratedCache<K,V> extends AbstractDelegatingAdvancedCache<K,V>
A decorator to a cache, which can be built with a specific set ofFlags. This set ofFlags will be applied to all cache invocations made via this decorator. In addition to cleaner and more readable code, this approach offers a performance benefit to usingAdvancedCache.withFlags(Flag...)API, thanks to internal optimizations that can be made when theFlagset is unchanging. Note thatDecoratedCachemust be the closest Delegate to the actual Cache implementation. All others must delegate to this DecoratedCache.- Since:
- 5.1
- Author:
- Manik Surtani, Sanne Grinovero, Tristan Tarrant
- See Also:
AdvancedCache.withFlags(Flag...)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.infinispan.cache.impl.AbstractDelegatingAdvancedCache
AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V>
-
-
Field Summary
-
Fields inherited from class org.infinispan.cache.impl.AbstractDelegatingAdvancedCache
cache
-
-
Constructor Summary
Constructors Constructor Description DecoratedCache(AdvancedCache<K,V> delegate)DecoratedCache(AdvancedCache<K,V> delegate, Object lockOwner, Flag... flags)DecoratedCache(AdvancedCache<K,V> delegate, Collection<Flag> flags)DecoratedCache(AdvancedCache<K,V> delegate, Flag... flags)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(Object listener)Adds a listener to the component.voidaddListener(Object listener, KeyFilter<? super K> filter)Adds a listener to the component.CacheSet<CacheEntry<K,V>>cacheEntrySet()Identical toCache.entrySet()but is typed to return CacheEntries instead of Entries.voidclear()Removes all mappings from the cache.CompletableFuture<Void>clearAsync()Asynchronous version ofMap.clear().Vcompute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)Vcompute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)An overloaded form of#compute(K, BiFunction), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.CompletableFuture<V>computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)Asynchronous version ofConcurrentMap.compute(Object, BiFunction).VcomputeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)VcomputeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)An overloaded form of#computeIfAbsent(K, Function), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.CompletableFuture<V>computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction)Asynchronous version ofConcurrentMap.computeIfAbsent(Object, Function).VcomputeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)VcomputeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)An overloaded form of#computeIfPresent(K, BiFunction), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.CompletableFuture<V>computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)Asynchronous version ofConcurrentMap.computeIfPresent(Object, BiFunction).booleancontainsKey(Object key)booleancontainsValue(Object value)CacheSet<Map.Entry<K,V>>entrySet()Returns a set view of the mappings contained in this cache and cache loader across the entire cluster.voidevict(K key)Evicts an entry from the memory of the cache.Vget(Object key)Map<K,V>getAll(Set<?> keys)Gets a collection of entries, returning them asMapof the values associated with the set of keys requested.CompletableFuture<Map<K,V>>getAllAsync(Set<?> keys)Map<K,CacheEntry<K,V>>getAllCacheEntries(Set<?> keys)Gets a collection of entries from theAdvancedCache, returning them asMapof the cache entries associated with the set of keys requested.CompletableFuture<V>getAsync(K key)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.CacheEntrygetCacheEntry(Object key)Retrieves a CacheEntry corresponding to a specific key.CompletableFuture<CacheEntry<K,V>>getCacheEntryAsync(Object key)Retrieves a CacheEntry corresponding to a specific key.ClassLoadergetClassLoader()Returns the cache loader associated associated with this cache.longgetFlagsBitSet()Map<K,V>getGroup(String groupName)It fetches all the keys which belong to the group.ObjectgetLockOwner()booleanisEmpty()CacheSet<K>keySet()Returns a set view of the keys contained in this cache and cache loader across the entire cluster.booleanlock(Collection<? extends K> keys)Locks collections of keys eagerly across cache nodes in a cluster.booleanlock(K... keys)Locks a given key or keys eagerly across cache nodes in a cluster.AdvancedCache<K,V>lockAs(Object lockOwner)Whenever this cache acquires a lock it will do so using the given Object as the owner of said lock.LockedStream<K,V>lockedStream()Returns a sequential stream using this Cache as the source.Vmerge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)Vmerge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)An overloaded form ofCache.merge(Object, Object, BiFunction), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.CompletableFuture<V>mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)Asynchronous version ofConcurrentMap.merge(Object, Object, BiFunction).AdvancedCache<K,V>noFlags()Unset all flags set on this cache usingAdvancedCache.withFlags(Flag...)orAdvancedCache.withFlags(Collection)methods.Vput(K key, V value)If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUESflag when invoking this method in order to make it behave as efficiently as possible (i.e.Vput(K key, V value, long lifespan, TimeUnit unit)An overloaded form ofBasicCache.put(Object, Object), which takes in lifespan parameters.Vput(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)An overloaded form ofBasicCache.put(Object, Object), which takes in lifespan parameters.Vput(K key, V value, Metadata metadata)An overloaded form of#put(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.voidputAll(Map<? extends K,? extends V> m)voidputAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)An overloaded form ofMap.putAll(Map), which takes in lifespan parameters.voidputAll(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.voidputAll(Map<? extends K,? extends V> map, Metadata metadata)An overloaded form ofMap.putAll(Map), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entries being stored, such as lifespan, version of value...etc.CompletableFuture<Void>putAllAsync(Map<? extends K,? extends V> data)Asynchronous version ofMap.putAll(Map).CompletableFuture<Void>putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)Asynchronous version ofBasicCache.putAll(Map, long, TimeUnit).CompletableFuture<Void>putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)Asynchronous version ofBasicCache.putAll(Map, long, TimeUnit, long, TimeUnit).CompletableFuture<Void>putAllAsync(Map<? extends K,? extends V> data, Metadata metadata)CompletableFuture<V>putAsync(K key, V value)Asynchronous version ofBasicCache.put(Object, Object).CompletableFuture<V>putAsync(K key, V value, long lifespan, TimeUnit unit)Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit).CompletableFuture<V>putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit, long, TimeUnit).CompletableFuture<V>putAsync(K key, V value, Metadata metadata)Asynchronous version ofAdvancedCache.put(Object, Object, Metadata)which stores metadata alongside the value.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 of#putForExternalRead(K, V), which takes in lifespan parameters.voidputForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)An overloaded form of#putForExternalRead(K, V), which takes in lifespan parameters.voidputForExternalRead(K key, V value, Metadata metadata)An overloaded form of#putForExternalRead(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.VputIfAbsent(K key, V value)VputIfAbsent(K key, V value, long lifespan, TimeUnit unit)An overloaded form ofConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.VputIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)An overloaded form ofConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.VputIfAbsent(K key, V value, Metadata metadata)An overloaded form of#putIfAbsent(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.CompletableFuture<V>putIfAbsentAsync(K key, V value)Asynchronous version ofConcurrentMap.putIfAbsent(Object, Object).CompletableFuture<V>putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit)Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit).CompletableFuture<V>putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit).CompletableFuture<V>putIfAbsentAsync(K key, V value, Metadata metadata)An overloaded form of#putIfAbsentAsync(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.protected InvocationContextreadContext(int size)Vremove(Object key)If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUESflag when invoking this method in order to make it behave as efficiently as possible (i.e.booleanremove(Object key, Object value)CompletableFuture<V>removeAsync(Object key)Asynchronous version ofBasicCache.remove(Object).CompletableFuture<Boolean>removeAsync(Object key, Object value)Asynchronous version ofConcurrentMap.remove(Object, Object).voidremoveGroup(String groupName)It removes all the key which belongs to a group.CompletableFuture<Boolean>removeLifespanExpired(K key, V value, Long lifespan)Attempts to remove the entry if it is expired.CompletableFuture<Boolean>removeMaxIdleExpired(K key, V value)Attempts to remove the entry for the given key, if it has expired due to max idle.Vreplace(K key, V value)Vreplace(K key, V value, long lifespan, TimeUnit unit)An overloaded form ofConcurrentMap.replace(Object, Object), which takes in lifespan parameters.Vreplace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)An overloaded form ofConcurrentMap.replace(Object, Object), which takes in lifespan parameters.Vreplace(K key, V value, Metadata metadata)An overloaded form of#replace(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.booleanreplace(K key, V oldValue, V newValue)booleanreplace(K key, V oldValue, V value, long lifespan, TimeUnit unit)An overloaded form ofConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.booleanreplace(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.booleanreplace(K key, V oldValue, V value, Metadata metadata)An overloaded form of#replace(K, V, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.CompletableFuture<V>replaceAsync(K key, V value)Asynchronous version ofConcurrentMap.replace(Object, Object).CompletableFuture<V>replaceAsync(K key, V value, long lifespan, TimeUnit unit)Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit).CompletableFuture<V>replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit, long, TimeUnit).CompletableFuture<V>replaceAsync(K key, V value, Metadata metadata)An overloaded form of#replaceAsync(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.CompletableFuture<Boolean>replaceAsync(K key, V oldValue, V newValue)Asynchronous version ofConcurrentMap.replace(Object, Object, Object).CompletableFuture<Boolean>replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit)Asynchronous version ofBasicCache.replace(Object, Object, Object, long, TimeUnit).CompletableFuture<Boolean>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).CompletableFuture<Boolean>replaceAsync(K key, V oldValue, V newValue, Metadata metadata)intsize()Returns a count of all elements in this cache and cache loader across the entire cluster.voidstop()Stops a cache.CacheCollection<V>values()Returns a collection view of the values contained in this cache across the entire cluster.AdvancedCache<K,V>with(ClassLoader classLoader)Using this operation, users can call anyAdvancedCacheoperation with a givenClassLoader.AdvancedCache<K,V>withEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> encoderClass)Performs any cache operations using the specifiedEncoder.AdvancedCache<K,V>withEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> keyEncoderClass, Class<? extends org.infinispan.commons.dataconversion.Encoder> valueEncoderClass)Performs any cache operations using the specified pair ofEncoder.AdvancedCache<K,V>withFlags(Collection<Flag> flags)An alternative toAdvancedCache.withFlags(Flag...)not requiring array allocation.AdvancedCache<K,V>withFlags(Flag... flags)A method that adds flags to any API call.AdvancedCache<K,V>withWrapping(Class<? extends org.infinispan.commons.dataconversion.Wrapper> wrapperClass)Performs any cache operations using the specifiedWrapper.AdvancedCache<K,V>withWrapping(Class<? extends org.infinispan.commons.dataconversion.Wrapper> keyWrapperClass, Class<? extends org.infinispan.commons.dataconversion.Wrapper> valueWrapperClass)Performs any cache operations using the specified pair ofWrapper.protected InvocationContextwriteContext(int size)-
Methods inherited from class org.infinispan.cache.impl.AbstractDelegatingAdvancedCache
addInterceptor, addInterceptorAfter, addInterceptorBefore, applyDelta, computeAsync, computeAsync, computeAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresentAsync, computeIfPresentAsync, computeIfPresentAsync, getAdvancedCache, getAndPutAll, getAsyncInterceptorChain, getAuthorizationManager, getAvailability, getBatchContainer, getCacheAvailability, getComponentRegistry, getDataContainer, getDistributionManager, getEvictionManager, getExpirationManager, getInterceptorChain, getInvocationContextContainer, getKeyDataConversion, getKeyEncoder, getKeyWrapper, getLockManager, getRpcManager, getStats, getTransactionManager, getValueDataConversion, getValueEncoder, getValueWrapper, getXAResource, isRebalancingEnabled, mergeAsync, mergeAsync, mergeAsync, putForExternalRead, putForExternalRead, removeInterceptor, removeInterceptor, setAvailability, setCacheAvailability, setRebalancingEnabled, transform, withKeyEncoding, withMediaType, withSubject
-
Methods inherited from class org.infinispan.cache.impl.AbstractDelegatingCache
addFilteredListener, addListener, addStorageFormatFilteredListener, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, endBatch, forEach, getCacheConfiguration, getCacheManager, getCacheName, getCacheStatus, getConfigurationAsProperties, getDelegate, getListeners, getName, getOrDefault, getStatus, getVersion, merge, merge, removeListener, replaceAll, set, shutdown, start, startBatch, toString, unwrapCache
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.infinispan.AdvancedCache
compute, computeAsync, computeIfAbsent, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, merge, mergeAsync
-
Methods inherited from interface org.infinispan.commons.api.BasicCache
compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getName, getVersion, merge, merge
-
Methods inherited from interface org.infinispan.Cache
compute, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfPresent, getCacheConfiguration, getCacheManager, getStatus, merge, shutdown
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
forEach, getOrDefault, replaceAll
-
Methods inherited from interface org.infinispan.notifications.FilteringListenable
addFilteredListener, addListener, addStorageFormatFilteredListener
-
Methods inherited from interface org.infinispan.notifications.Listenable
getListeners, removeListener
-
-
-
-
Constructor Detail
-
DecoratedCache
public DecoratedCache(AdvancedCache<K,V> delegate)
-
DecoratedCache
public DecoratedCache(AdvancedCache<K,V> delegate, Flag... flags)
-
DecoratedCache
public DecoratedCache(AdvancedCache<K,V> delegate, Collection<Flag> flags)
-
DecoratedCache
public DecoratedCache(AdvancedCache<K,V> delegate, Object lockOwner, Flag... flags)
-
-
Method Detail
-
with
public AdvancedCache<K,V> with(ClassLoader classLoader)
Description copied from interface:AdvancedCacheUsing this operation, users can call anyAdvancedCacheoperation with a givenClassLoader. This means that anyClassLoaderhappening as a result of the cache operation will be done using theClassLoadergiven. For example: When users store POJO instances in caches configured withStoreAsBinaryConfiguration, these instances are transformed into byte arrays. When these entries are read from the cache, a lazy unmarshalling process happens where these byte arrays are transformed back into POJO instances. UsingAdvancedCache.with(ClassLoader)when reading that enables users to provide the class loader that should be used when trying to locate the classes that are constructed as a result of the unmarshalling process.cache.with(classLoader).get(key);Note that for the flag to take effect, the cache operation must be invoked on the instance returned by this method. As an alternative to setting this on every invocation, users could also consider using theDecoratedCachewrapper, as this allows for more readable code. E.g.:Cache classLoaderSpecificCache = new DecoratedCache(cache, classLoader); classLoaderSpecificCache.get(key1); classLoaderSpecificCache.get(key2); classLoaderSpecificCache.get(key3);- Specified by:
within interfaceAdvancedCache<K,V>- Overrides:
within classAbstractDelegatingAdvancedCache<K,V>- Returns:
- an
AdvancedCacheinstance upon which operations can be called with a particularClassLoader.
-
withFlags
public AdvancedCache<K,V> withFlags(Flag... flags)
Description copied from interface:AdvancedCacheA method that adds flags to any API call. For example, consider the following code snippet:cache.withFlags(Flag.FORCE_WRITE_LOCK).get(key);
will invoke a cache.get() with a write lock forced. Note that for the flag to take effect, the cache operation must be invoked on the instance returned by this method. As an alternative to setting this on every invocation, users could also consider using theDecoratedCachewrapper, as this allows for more readable code. E.g.:Cache forceWriteLockCache = new DecoratedCache(cache, Flag.FORCE_WRITE_LOCK); forceWriteLockCache.get(key1); forceWriteLockCache.get(key2); forceWriteLockCache.get(key3);- Specified by:
withFlagsin interfaceAdvancedCache<K,V>- Overrides:
withFlagsin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
flags- a set of flags to apply. See theFlagdocumentation.- Returns:
- an
AdvancedCacheinstance on which a real operation is to be invoked, if the flags are to be applied.
-
withFlags
public AdvancedCache<K,V> withFlags(Collection<Flag> flags)
Description copied from interface:AdvancedCacheAn alternative toAdvancedCache.withFlags(Flag...)not requiring array allocation.- Specified by:
withFlagsin interfaceAdvancedCache<K,V>- Overrides:
withFlagsin classAbstractDelegatingAdvancedCache<K,V>- Returns:
-
noFlags
public AdvancedCache<K,V> noFlags()
Description copied from interface:AdvancedCacheUnset all flags set on this cache usingAdvancedCache.withFlags(Flag...)orAdvancedCache.withFlags(Collection)methods.- Specified by:
noFlagsin interfaceAdvancedCache<K,V>- Overrides:
noFlagsin classAbstractDelegatingAdvancedCache<K,V>- Returns:
- Cache not applying any flags to the command; possibly
this.
-
withEncoding
public AdvancedCache<K,V> withEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> encoderClass)
Description copied from interface:AdvancedCachePerforms any cache operations using the specifiedEncoder.- Specified by:
withEncodingin interfaceAdvancedCache<K,V>- Overrides:
withEncodingin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
encoderClass-Encoderused for both keys and values.- Returns:
- an instance of
AdvancedCachewhere all operations will use the supplied encoder.
-
withEncoding
public AdvancedCache<K,V> withEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> keyEncoderClass, Class<? extends org.infinispan.commons.dataconversion.Encoder> valueEncoderClass)
Description copied from interface:AdvancedCachePerforms any cache operations using the specified pair ofEncoder.- Specified by:
withEncodingin interfaceAdvancedCache<K,V>- Overrides:
withEncodingin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
keyEncoderClass-Encoderfor the keys.valueEncoderClass-Encoderfor the values.- Returns:
- an instance of
AdvancedCachewhere all operations will use the supplied encoders.
-
withWrapping
public AdvancedCache<K,V> withWrapping(Class<? extends org.infinispan.commons.dataconversion.Wrapper> wrapperClass)
Description copied from interface:AdvancedCachePerforms any cache operations using the specifiedWrapper.- Specified by:
withWrappingin interfaceAdvancedCache<K,V>- Overrides:
withWrappingin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
wrapperClass-Wrapperfor the keys and values.- Returns:
- an instance of
AdvancedCachewhere all operations will use the supplied wrapper.
-
withWrapping
public AdvancedCache<K,V> withWrapping(Class<? extends org.infinispan.commons.dataconversion.Wrapper> keyWrapperClass, Class<? extends org.infinispan.commons.dataconversion.Wrapper> valueWrapperClass)
Description copied from interface:AdvancedCachePerforms any cache operations using the specified pair ofWrapper.- Specified by:
withWrappingin interfaceAdvancedCache<K,V>- Overrides:
withWrappingin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
keyWrapperClass-Wrapperfor the keys.valueWrapperClass-Wrapperfor the values.- Returns:
AdvancedCachewhere all operations will use the supplied wrappers.
-
lockAs
public AdvancedCache<K,V> lockAs(Object lockOwner)
Description copied from interface:AdvancedCacheWhenever this cache acquires a lock it will do so using the given Object as the owner of said lock.This can be useful when a lock may have been manually acquired and you wish to reuse that lock across invocations.
Great care should be taken with this command as misuse can very easily lead to deadlocks.
- Specified by:
lockAsin interfaceAdvancedCache<K,V>- Overrides:
lockAsin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
lockOwner- the lock owner to lock any keys as- Returns:
- an
AdvancedCacheinstance on which when an operation is invoked it will use lock owner object to acquire any locks
-
getLockOwner
public Object getLockOwner()
-
lockedStream
public LockedStream<K,V> lockedStream()
Description copied from interface:AdvancedCacheReturns a sequential stream using this Cache as the source. This stream is very similar to using theCacheStreamreturned from theCacheCollection.stream()method of the collection returned viaAdvancedCache.cacheEntrySet(). The use of this locked stream is that when an entry is being processed by the user the entry is locked for the invocation preventing a different thread from modifying it.Note that this stream is not supported when using a optimistic transactional or simple cache. Both non transactional and pessimistic transactional caches are supported.
The stream will not share any ongoing transaction the user may have. Code executed by the stream should be treated as completely independent. That is any operation performed via the stream will require the user to start their own transaction or will be done intrinsically on the invocation. Note that if there is an ongoing transaction that has a lock on a key from the cache, that it will cause a deadlock.
Currently simple cache,
ConfigurationBuilder.simpleCache(boolean)was set to true, and optimistic caches,TransactionConfigurationBuilder.lockingMode(LockingMode)was set toLockingMode.OPTIMISTIC, do not support this method. In this case it will throw anUnsupportedOperationException. This restriction may be removed in a future version. Also this method cannot be used on a cache that has a lock owner already specified viaAdvancedCache.lockAs(Object)as this could lead to a deadlock or the release of locks early and will throw anIllegalStateException.- Specified by:
lockedStreamin interfaceAdvancedCache<K,V>- Overrides:
lockedStreamin classAbstractDelegatingAdvancedCache<K,V>- Returns:
- the locked stream
-
getClassLoader
public ClassLoader getClassLoader()
Description copied from interface:AdvancedCacheReturns the cache loader associated associated with this cache. As an alternative to setting this on every invocation, users could also consider using theDecoratedCachewrapper.- Specified by:
getClassLoaderin interfaceAdvancedCache<K,V>- Overrides:
getClassLoaderin classAbstractDelegatingAdvancedCache<K,V>- Returns:
- this cache's cache loader
-
stop
public void stop()
Description copied from interface:CacheStops a cache. If the cache is clustered, this only stops the cache on the node where it is being invoked. If you need to stop the cache across a cluster, use theCache.shutdown()method.
-
lock
public boolean lock(K... keys)
Description copied from interface:AdvancedCacheLocks a given key or keys eagerly across cache nodes in a cluster.Keys can be locked eagerly in the context of a transaction only.
- Specified by:
lockin interfaceAdvancedCache<K,V>- Overrides:
lockin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
keys- the keys to lock- Returns:
- true if the lock acquisition attempt was successful for all keys; false will only be returned if
the lock acquisition timed out and the operation has been called with
Flag.FAIL_SILENTLY.
-
lock
public boolean lock(Collection<? extends K> keys)
Description copied from interface:AdvancedCacheLocks collections of keys eagerly across cache nodes in a cluster.Collections of keys can be locked eagerly in the context of a transaction only.
- Specified by:
lockin interfaceAdvancedCache<K,V>- Overrides:
lockin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
keys- collection of keys to lock- Returns:
- true if the lock acquisition attempt was successful for all keys; false will only be returned if
the lock acquisition timed out and the operation has been called with
Flag.FAIL_SILENTLY.
-
putForExternalRead
public void putForExternalRead(K key, V value)
Description copied from interface:CacheUnder special operating behavior, associates the value with the specified key.- Only goes through if the
key specified does not exist; no-op otherwise (similar to
ConcurrentMap.putIfAbsent(Object, Object)) - Force asynchronous mode for replication to prevent any blocking.
- invalidation does not take place.
- 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this method is a no-op, and swallows the timeout exception.
- Ongoing transactions are suspended before this call, so failures here will not affect any ongoing transactions.
- Errors and exceptions are 'silent' - logged at a much lower level than normal, and this method does not throw exceptions
- Specified by:
putForExternalReadin interfaceCache<K,V>- Overrides:
putForExternalReadin classAbstractDelegatingCache<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
public void putForExternalRead(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#putForExternalRead(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
putForExternalReadin interfaceAdvancedCache<K,V>- Overrides:
putForExternalReadin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified keymetadata- information to store alongside the new value
-
putForExternalRead
public void putForExternalRead(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:CacheAn overloaded form of#putForExternalRead(K, V), which takes in lifespan parameters.- Specified by:
putForExternalReadin interfaceCache<K,V>- Overrides:
putForExternalReadin classAbstractDelegatingCache<K,V>- Parameters:
key- key to usevalue- value to storelifespan- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit- unit of measurement for the lifespan
-
putForExternalRead
public void putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Description copied from interface:CacheAn overloaded form of#putForExternalRead(K, V), which takes in lifespan parameters.- Specified by:
putForExternalReadin interfaceCache<K,V>- Overrides:
putForExternalReadin classAbstractDelegatingCache<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
public void evict(K key)
Description copied from interface:CacheEvicts an entry from the memory of the cache. Note that the entry is not removed from any configured cache stores or any other caches in the cluster (if used in a clustered mode). UseBasicCache.remove(Object)to remove an entry from the entire cache system. This method is designed to evict an entry from memory to free up memory used by the application. This method uses a 0 lock acquisition timeout so it does not block in attempting to acquire locks. It behaves as a no-op if the lock on the entry cannot be acquired immediately. Important: this method should not be called from within a transaction scope.
-
put
public V put(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCacheAn overloaded form ofBasicCache.put(Object, Object), which takes in lifespan parameters.- Specified by:
putin interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
putin classAbstractDelegatingCache<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
public V putIfAbsent(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCacheAn overloaded form ofConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.- Specified by:
putIfAbsentin interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
putIfAbsentin classAbstractDelegatingCache<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
public void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCacheAn 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:
putAllin interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
putAllin classAbstractDelegatingCache<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
public V replace(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCacheAn overloaded form ofConcurrentMap.replace(Object, Object), which takes in lifespan parameters.- Specified by:
replacein interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
replacein classAbstractDelegatingCache<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
public boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCacheAn overloaded form ofConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.- Specified by:
replacein interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
replacein classAbstractDelegatingCache<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:org.infinispan.commons.api.BasicCacheAn overloaded form ofBasicCache.put(Object, Object), which takes in lifespan parameters.- Specified by:
putin interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
putin classAbstractDelegatingCache<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:org.infinispan.commons.api.BasicCacheAn overloaded form ofConcurrentMap.putIfAbsent(Object, Object), which takes in lifespan parameters.- Specified by:
putIfAbsentin interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
putIfAbsentin classAbstractDelegatingCache<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:org.infinispan.commons.api.BasicCacheAn 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:
putAllin interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
putAllin classAbstractDelegatingCache<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:org.infinispan.commons.api.BasicCacheAn overloaded form ofConcurrentMap.replace(Object, Object), which takes in lifespan parameters.- Specified by:
replacein interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
replacein classAbstractDelegatingCache<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:org.infinispan.commons.api.BasicCacheAn overloaded form ofConcurrentMap.replace(Object, Object, Object), which takes in lifespan parameters.- Specified by:
replacein interfaceorg.infinispan.commons.api.BasicCache<K,V>- Overrides:
replacein classAbstractDelegatingCache<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
-
putAsync
public CompletableFuture<V> putAsync(K key, V value)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofBasicCache.put(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.
-
putAsync
public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofBasicCache.put(Object, Object, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
putAsyncin classAbstractDelegatingCache<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:org.infinispan.commons.api.AsyncCacheAsynchronous 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:
putAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
putAsyncin classAbstractDelegatingCache<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
public CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofMap.putAll(Map). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAllAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
putAllAsyncin classAbstractDelegatingCache<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:org.infinispan.commons.api.AsyncCacheAsynchronous version ofBasicCache.putAll(Map, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putAllAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
putAllAsyncin classAbstractDelegatingCache<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:org.infinispan.commons.api.AsyncCacheAsynchronous 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:
putAllAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
putAllAsyncin classAbstractDelegatingCache<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
-
putAllAsync
public CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data, Metadata metadata)
- Specified by:
putAllAsyncin interfaceAdvancedCache<K,V>- Overrides:
putAllAsyncin classAbstractDelegatingAdvancedCache<K,V>
-
clearAsync
public CompletableFuture<Void> clearAsync()
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofMap.clear(). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
clearAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
clearAsyncin classAbstractDelegatingCache<K,V>- Returns:
- a future containing a void return type
-
putIfAbsentAsync
public CompletableFuture<V> putIfAbsentAsync(K key, V value)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofConcurrentMap.putIfAbsent(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putIfAbsentAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
putIfAbsentAsyncin classAbstractDelegatingCache<K,V>- Parameters:
key- key to usevalue- value to store- Returns:
- a future containing the old value replaced.
-
putIfAbsentAsync
public CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
putIfAbsentAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
putIfAbsentAsyncin classAbstractDelegatingCache<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:org.infinispan.commons.api.AsyncCacheAsynchronous 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:
putIfAbsentAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
putIfAbsentAsyncin classAbstractDelegatingCache<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
-
putIfAbsentAsync
public CompletableFuture<V> putIfAbsentAsync(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#putIfAbsentAsync(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
putIfAbsentAsyncin interfaceAdvancedCache<K,V>- Overrides:
putIfAbsentAsyncin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified keymetadata- information to store alongside the new value- Returns:
- A future containing the previous value associated with the specified key, or null if there was no mapping for the key.
-
removeAsync
public CompletableFuture<V> removeAsync(Object key)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofBasicCache.remove(Object). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
removeAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
removeAsyncin classAbstractDelegatingCache<K,V>- Parameters:
key- key to remove- Returns:
- a future containing the value removed
-
removeAsync
public CompletableFuture<Boolean> removeAsync(Object key, Object value)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofConcurrentMap.remove(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
removeAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
removeAsyncin classAbstractDelegatingCache<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
-
removeLifespanExpired
public CompletableFuture<Boolean> removeLifespanExpired(K key, V value, Long lifespan)
Description copied from interface:AdvancedCacheAttempts to remove the entry if it is expired. Due to expired entries not being consistent across nodes, this will still attempt to remove the value if it is not present. Note that this will raise an expired event even if the entry is not present. Normally this method should never be invoked except by theExpirationManager.This command will only remove the value if the value and lifespan also match if provided.
This method will suspend any ongoing transaction and start a new one just for the invocation of this command. It is automatically committed or rolled back after the command completes, either successfully or via an exception.
NOTE: This method may be removed at any point including in a minor release and is not supported for external usage.
- Specified by:
removeLifespanExpiredin interfaceAdvancedCache<K,V>- Overrides:
removeLifespanExpiredin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- the key that is expiringvalue- the value that mapped to the given. Null means it will match any valuelifespan- the lifespan that should match. If null is provided it will match any lifespan value- Returns:
- if the entry was removed
-
removeMaxIdleExpired
public CompletableFuture<Boolean> removeMaxIdleExpired(K key, V value)
Description copied from interface:AdvancedCacheAttempts to remove the entry for the given key, if it has expired due to max idle. This command first locks the key and then verifies that the entry has expired via maxIdle across all nodes. If it has this will then remove the given key.This method returns a boolean when it has determined if the entry has expired. This is useful for when a backup node invokes this command for a get that found the entry expired. This way the node can return back to the caller much faster when the entry is not expired and do any additional processing asynchronously if needed.
This method will suspend any ongoing transaction and start a new one just for the invocation of this command. It is automatically committed or rolled back after the command completes, either successfully or via an exception.
NOTE: This method may be removed at any point including in a minor release and is not supported for external usage.
- Specified by:
removeMaxIdleExpiredin interfaceAdvancedCache<K,V>- Overrides:
removeMaxIdleExpiredin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- the key that expired via max idle for the given entry- Returns:
- if the entry was removed
-
replaceAsync
public CompletableFuture<V> replaceAsync(K key, V value)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofConcurrentMap.replace(Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
replaceAsyncin classAbstractDelegatingCache<K,V>- Parameters:
key- key to removevalue- value to store- Returns:
- a future containing the previous value overwritten
-
replaceAsync
public CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
replaceAsyncin classAbstractDelegatingCache<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:org.infinispan.commons.api.AsyncCacheAsynchronous 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:
replaceAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
replaceAsyncin classAbstractDelegatingCache<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
public CompletableFuture<V> replaceAsync(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#replaceAsync(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
replaceAsyncin interfaceAdvancedCache<K,V>- Overrides:
replaceAsyncin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is associatedvalue- value to be associated with the specified keymetadata- information to store alongside the new value- Returns:
- the future that contains previous value associated with the specified key, or null if there was no mapping for the key.
-
replaceAsync
public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofConcurrentMap.replace(Object, Object, Object). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
replaceAsyncin classAbstractDelegatingCache<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:org.infinispan.commons.api.AsyncCacheAsynchronous 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:
replaceAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
replaceAsyncin classAbstractDelegatingCache<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:org.infinispan.commons.api.AsyncCacheAsynchronous 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:
replaceAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
replaceAsyncin classAbstractDelegatingCache<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
-
replaceAsync
public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, Metadata metadata)
- Specified by:
replaceAsyncin interfaceAdvancedCache<K,V>- Overrides:
replaceAsyncin classAbstractDelegatingAdvancedCache<K,V>
-
getAsync
public CompletableFuture<V> getAsync(K key)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous 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:
getAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
getAsyncin classAbstractDelegatingCache<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
public CompletableFuture<Map<K,V>> getAllAsync(Set<?> keys)
- Specified by:
getAllAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
getAllAsyncin classAbstractDelegatingAdvancedCache<K,V>
-
size
public int size()
Description copied from interface:CacheReturns a count of all elements in this cache and cache loader across the entire cluster. Only a subset of entries is held in memory at a time when using a loader or remote entries, to prevent possible memory issues, however the loading of said entries can still be vary slow. If there are performance concerns then theFlag.SKIP_CACHE_LOADflag should be used to avoid hitting the cache loader in case if this is not needed in the size calculation. Also if you want the local contents only you can use theFlag.CACHE_MODE_LOCALflag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOADis also configured. If this method is used in a transactional context, note this method will not bring additional values into the transaction context and thus objects that haven't yet been read will act in aIsolationLevel.READ_COMMITTEDbehavior irrespective of the configured isolation level. However values that have been previously modified or read that are in the context will be adhered to. e.g. any write modification or any previous read when usingIsolationLevel.REPEATABLE_READThis method should only be used for debugging purposes such as to verify that the cache contains all the keys entered. Any other use involving execution of this method on a production system is not recommended.
-
isEmpty
public boolean isEmpty()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>- Overrides:
containsKeyin classAbstractDelegatingCache<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>- Overrides:
containsValuein classAbstractDelegatingCache<K,V>
-
getAll
public Map<K,V> getAll(Set<?> keys)
Description copied from interface:AdvancedCacheGets a collection of entries, returning them asMapof the values associated with the set of keys requested.If the cache is configured read-through, and a get for a key would return null because an entry is missing from the cache, the Cache's
CacheLoaderis called in an attempt to load the entry. If an entry cannot be loaded for a given key, the returned Map will contain null for value of the key.Unlike other bulk methods if this invoked in an existing transaction all entries will be stored in the current transactional context
The returned
Mapwill be a copy and updates to the map will not be reflected in the Cache and vice versa. The keys and values themselves however may not be copies depending on if storeAsBinary is enabled and the value was retrieved from the local node.- Specified by:
getAllin interfaceAdvancedCache<K,V>- Overrides:
getAllin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
keys- The keys whose associated values are to be returned.- Returns:
- A map of entries that were found for the given keys. If an entry is not found for a given key, it will not be in the returned map.
-
getAllCacheEntries
public Map<K,CacheEntry<K,V>> getAllCacheEntries(Set<?> keys)
Description copied from interface:AdvancedCacheGets a collection of entries from theAdvancedCache, returning them asMapof the cache entries associated with the set of keys requested.If the cache is configured read-through, and a get for a key would return null because an entry is missing from the cache, the Cache's
CacheLoaderis called in an attempt to load the entry. If an entry cannot be loaded for a given key, the returned Map will contain null for value of the key.Unlike other bulk methods if this invoked in an existing transaction all entries will be stored in the current transactional context
The returned
Mapwill be a copy and updates to the map will not be reflected in the Cache and vice versa. The keys and values themselves however may not be copies depending on if storeAsBinary is enabled and the value was retrieved from the local node.- Specified by:
getAllCacheEntriesin interfaceAdvancedCache<K,V>- Overrides:
getAllCacheEntriesin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
keys- The keys whose associated values are to be returned.- Returns:
- A map of entries that were found for the given keys. Keys not found in the cache are present in the map with null values.
-
put
public V put(K key, V value)
Description copied from interface:org.infinispan.commons.api.BasicCacheIf the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUESflag when invoking this method in order to make it behave as efficiently as possible (i.e. avoiding needless remote or network calls).
-
remove
public V remove(Object key)
Description copied from interface:org.infinispan.commons.api.BasicCacheIf the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.IGNORE_RETURN_VALUESflag when invoking this method in order to make it behave as efficiently as possible (i.e. avoiding needless remote or network calls).
-
putAll
public void putAll(Map<? extends K,? extends V> map, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form ofMap.putAll(Map), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entries being stored, such as lifespan, version of value...etc.- Specified by:
putAllin interfaceAdvancedCache<K,V>- Overrides:
putAllin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
map- the values to storemetadata- information to store alongside the value(s)
-
clear
public void clear()
Description copied from interface:CacheRemoves all mappings from the cache. Note: This should never be invoked in production unless you can guarantee no other invocations are ran concurrently. If the cache is transactional, it will not interact with the transaction.
-
keySet
public CacheSet<K> keySet()
Description copied from interface:CacheReturns a set view of the keys contained in this cache and cache loader across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing set is just returned. Invocation on the set itself is when the various operations are ran.Unsupported Operations
Care should be taken when invokingSet.toArray(),Set.toArray(Object[]),Set.size(),Set.retainAll(Collection)andSet.iterator()methods as they will traverse the entire contents of the cluster including a configuredCacheLoaderand remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryErrordue to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operationsSupported Flags
Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets. If there are performance concerns then theFlag.SKIP_CACHE_LOADflag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to preventOutOfMemoryError) Also if you want the local contents only you can use theFlag.CACHE_MODE_LOCALflag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOADis also configured.Iterator Use
This class implements theCloseableIteratorSetinterface which creates aCloseableIteratorinstead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.Unsupported Operations
Due to not being able to add null values the following methods are not supported and will throwUnsupportedOperationExceptionif invoked.Set.add(Object)Set.addAll(java.util.Collection)
-
getGroup
public Map<K,V> getGroup(String groupName)
Description copied from interface:AdvancedCacheIt fetches all the keys which belong to the group. Semantically, it iterates over all the keys in memory and persistence, and performs a read operation in the keys found. Multiple invocations inside a transaction ensures that all the keys previous read are returned and it may return newly added keys to the group from other committed transactions (also known as phantom reads). Themapreturned is immutable and represents the group at the time of the invocation. If you want to add or remove keys from a group useBasicCache.put(Object, Object)andBasicCache.remove(Object). To remove all the keys in the group useAdvancedCache.removeGroup(String). To improve performance you may use theflagFlag.SKIP_CACHE_LOADto avoid fetching the key/value from persistence. However, you will get an inconsistent snapshot of the group.- Specified by:
getGroupin interfaceAdvancedCache<K,V>- Overrides:
getGroupin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
groupName- the group name.- Returns:
- an immutable
Mapwith the key/value pairs.
-
removeGroup
public void removeGroup(String groupName)
Description copied from interface:AdvancedCacheIt removes all the key which belongs to a group. Semantically, it fetches the most recent group keys/values and removes them. Note that, concurrent addition perform by other transactions/threads to the group may not be removed.- Specified by:
removeGroupin interfaceAdvancedCache<K,V>- Overrides:
removeGroupin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
groupName- the group name.
-
values
public CacheCollection<V> values()
Description copied from interface:CacheReturns a collection view of the values contained in this cache across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing collection is just returned. Invocation on the collection itself is when the various operations are ran. Care should be taken when invokingCollection.toArray(),Collection.toArray(Object[]),Collection.size(),Collection.retainAll(Collection)andCollection.iterator()methods as they will traverse the entire contents of the cluster including a configuredCacheLoaderand remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryErrordue to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operations *Supported Flags
Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets. If there are performance concerns then theFlag.SKIP_CACHE_LOADflag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to preventOutOfMemoryError) Also if you want the local contents only you can use theFlag.CACHE_MODE_LOCALflag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOADis also configured.Iterator Use
This class implements the
CloseableIteratorCollectioninterface which creates aCloseableIteratorinstead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.The iterator retrieved using
CloseableIteratorCollection.iterator()supports the remove method, however the iterator retrieved fromCacheStream.iterator()will not support remove.Unsupported Operations
Due to not being able to add null values the following methods are not supported and will throwUnsupportedOperationExceptionif invoked.Set.add(Object)Set.addAll(java.util.Collection)
-
entrySet
public CacheSet<Map.Entry<K,V>> entrySet()
Description copied from interface:CacheReturns a set view of the mappings contained in this cache and cache loader across the entire cluster. Modifications and changes to the cache will be reflected in the set and vice versa. When this method is called nothing is actually queried as the backing set is just returned. Invocation on the set itself is when the various operations are ran. Care should be taken when invokingSet.toArray(),Set.toArray(Object[]),Set.size(),Set.retainAll(Collection)andSet.iterator()methods as they will traverse the entire contents of the cluster including a configuredCacheLoaderand remote entries. The former 2 methods especially have a very high likely hood of causing aOutOfMemoryErrordue to storing all the keys in the entire cluster in the array. Use involving execution of this method on a production system is not recommended as they can be quite expensive operations *Supported Flags
Note any flag configured for the cache will also be passed along to the backing set when it was created. If additional flags are configured on the cache they will not affect any existing backings sets. If there are performance concerns then theFlag.SKIP_CACHE_LOADflag should be used to avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to preventOutOfMemoryError) Also if you want the local contents only you can use theFlag.CACHE_MODE_LOCALflag so that other remote nodes are not queried for data. However the loader will still be used unless the previously mentionedFlag.SKIP_CACHE_LOADis also configured.Modifying or Adding Entries
An entry's value is supported to be modified by using theMap.Entry.setValue(Object)and it will update the cache as well. Also this backing set does allow addition of a new Map.Entry(s) via theSet.add(Object)orSet.addAll(java.util.Collection)methods.Iterator Use
This class implements theCloseableIteratorSetinterface which creates aCloseableIteratorinstead of a regular one. This means this iterator must be explicitly closed either through try with resource or calling the close method directly. Technically this iterator will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.
-
cacheEntrySet
public CacheSet<CacheEntry<K,V>> cacheEntrySet()
Description copied from interface:AdvancedCacheIdentical toCache.entrySet()but is typed to return CacheEntries instead of Entries. Please see the other method for a description of its behaviors.This method is needed since nested generics do not support covariance
- Specified by:
cacheEntrySetin interfaceAdvancedCache<K,V>- Overrides:
cacheEntrySetin classAbstractDelegatingAdvancedCache<K,V>- Returns:
- the entry set containing all of the CacheEntries
- See Also:
Cache.entrySet()
-
putIfAbsent
public V putIfAbsent(K key, V value)
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
putIfAbsentin interfaceMap<K,V>- Overrides:
putIfAbsentin classAbstractDelegatingCache<K,V>
-
compute
public V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
Description copied from interface:CacheWhen this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate
Externalizeror beSerializableitself.For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
Description copied from interface:CacheWhen this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate
Externalizeror beSerializableitself.For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
- Specified by:
computeIfPresentin interfaceCache<K,V>- Specified by:
computeIfPresentin interfaceConcurrentMap<K,V>- Specified by:
computeIfPresentin interfaceMap<K,V>- Overrides:
computeIfPresentin classAbstractDelegatingCache<K,V>
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
Description copied from interface:CacheWhen this method is used on a clustered cache, either replicated or distributed, the function will be serialized to owning nodes to perform the operation in the most performant way. However this means the function must have an appropriate
Externalizeror beSerializableitself.For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
- Specified by:
computeIfAbsentin interfaceCache<K,V>- Specified by:
computeIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
computeIfAbsentin interfaceMap<K,V>- Overrides:
computeIfAbsentin classAbstractDelegatingCache<K,V>
-
merge
public V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
Description copied from interface:CacheWhen this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized to owning nodes to perform the operation in the most performant way. However this means the bifunction must have an appropriate
Externalizeror beSerializableitself.For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofConcurrentMap.compute(Object, BiFunction). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
computeAsyncin classAbstractDelegatingAdvancedCache<K,V>
-
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofConcurrentMap.computeIfPresent(Object, BiFunction). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfPresentAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
computeIfPresentAsyncin classAbstractDelegatingAdvancedCache<K,V>
-
computeIfAbsentAsync
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofConcurrentMap.computeIfAbsent(Object, Function). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfAbsentAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
computeIfAbsentAsyncin classAbstractDelegatingAdvancedCache<K,V>
-
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
Description copied from interface:org.infinispan.commons.api.AsyncCacheAsynchronous version ofConcurrentMap.merge(Object, Object, BiFunction). This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
mergeAsyncin interfaceorg.infinispan.commons.api.AsyncCache<K,V>- Overrides:
mergeAsyncin classAbstractDelegatingAdvancedCache<K,V>
-
getFlagsBitSet
public long getFlagsBitSet()
-
addListener
public void addListener(Object listener)
Description copied from interface:ListenableAdds a listener to the component. Typically, listeners would need to be annotated withListenerand further to that, contain methods annotated appropriately, otherwise the listener will not be registered. See theListenerannotation for more information.- Specified by:
addListenerin interfaceListenable- Overrides:
addListenerin classAbstractDelegatingCache<K,V>- Parameters:
listener- must not be null.
-
addListener
public void addListener(Object listener, KeyFilter<? super K> filter)
Description copied from interface:FilteringListenableAdds a listener to the component. Typically, listeners would need to be annotated withListenerand further to that, contain methods annotated appropriately, otherwise the listener will not be registered. See theListenerannotation for more information.- Specified by:
addListenerin interfaceFilteringListenable<K,V>- Overrides:
addListenerin classAbstractDelegatingCache<K,V>- Parameters:
listener- must not be null.
-
put
public V put(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#put(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.- Specified by:
putin interfaceAdvancedCache<K,V>- Overrides:
putin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key to usevalue- value to storemetadata- information to store alongside the value- Returns:
- the previous value associated with key, or null if there was no mapping for key.
-
putAsync
public CompletableFuture<V> putAsync(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCacheAsynchronous version ofAdvancedCache.put(Object, Object, Metadata)which stores metadata alongside the value. This method does not block on remote calls, even if your cache mode is synchronous. Has no benefit overAdvancedCache.put(Object, Object, Metadata)if used in LOCAL mode.- Specified by:
putAsyncin interfaceAdvancedCache<K,V>- Overrides:
putAsyncin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key to usevalue- value to storemetadata- information to store alongside the new value- Returns:
- a future containing the old value replaced.
-
putIfAbsent
public V putIfAbsent(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#putIfAbsent(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
putIfAbsentin interfaceAdvancedCache<K,V>- Overrides:
putIfAbsentin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified keymetadata- information to store alongside the new value- Returns:
- the previous value associated with the specified key, or null if there was no mapping for the key.
-
replace
public boolean replace(K key, V oldValue, V value, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#replace(K, V, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
replacein interfaceAdvancedCache<K,V>- Overrides:
replacein classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is associatedoldValue- value expected to be associated with the specified keyvalue- value to be associated with the specified keymetadata- information to store alongside the new value- Returns:
- true if the value was replaced
-
replace
public V replace(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#replace(K, V), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
replacein interfaceAdvancedCache<K,V>- Overrides:
replacein classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is associatedvalue- value to be associated with the specified keymetadata- information to store alongside the new value- Returns:
- the previous value associated with the specified key, or null if there was no mapping for the key.
-
compute
public V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#compute(K, BiFunction), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.- Specified by:
computein interfaceAdvancedCache<K,V>- Overrides:
computein classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is associatedremappingFunction- function to be applied to the specified key/valuemetadata- information to store alongside the new value- Returns:
- the previous value associated with the specified key, or null if remapping function is gives null.
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#computeIfPresent(K, BiFunction), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
computeIfPresentin interfaceAdvancedCache<K,V>- Overrides:
computeIfPresentin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is associatedremappingFunction- function to be applied to the specified key/valuemetadata- information to store alongside the new value- Returns:
- the previous value associated with the specified key, or null if there was no mapping for the key.
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form of#computeIfAbsent(K, Function), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
computeIfAbsentin interfaceAdvancedCache<K,V>- Overrides:
computeIfAbsentin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- key with which the specified value is associatedmappingFunction- function to be applied to the specified keymetadata- information to store alongside the new value- Returns:
- the value created with the mapping function associated with the specified key, or the previous value associated with the specified key if the key is not absent.
-
merge
public V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)
Description copied from interface:AdvancedCacheAn overloaded form ofCache.merge(Object, Object, BiFunction), which takes in an instance ofMetadatawhich can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadatais only stored if the call is successful.- Specified by:
mergein interfaceAdvancedCache<K,V>- Overrides:
mergein classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- , key with which the resulting value is to be associatedvalue- , 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 keyremappingFunction- , the function to recompute a value if presentmetadata- , information to store alongside the new value- Returns:
- the new value associated with the specified key, or null if no value is associated with the key
-
getCacheEntry
public CacheEntry getCacheEntry(Object key)
Description copied from interface:AdvancedCacheRetrieves a CacheEntry corresponding to a specific key.- Specified by:
getCacheEntryin interfaceAdvancedCache<K,V>- Overrides:
getCacheEntryin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- the key whose associated cache entry is to be returned- Returns:
- the cache entry to which the specified key is mapped, or
nullif this map contains no mapping for the key
-
getCacheEntryAsync
public CompletableFuture<CacheEntry<K,V>> getCacheEntryAsync(Object key)
Description copied from interface:AdvancedCacheRetrieves a CacheEntry corresponding to a specific key.- Specified by:
getCacheEntryAsyncin interfaceAdvancedCache<K,V>- Overrides:
getCacheEntryAsyncin classAbstractDelegatingAdvancedCache<K,V>- Parameters:
key- the key whose associated cache entry is to be returned- Returns:
- a future with the cache entry to which the specified key is mapped, or with
nullif this map contains no mapping for the key
-
readContext
protected InvocationContext readContext(int size)
-
writeContext
protected InvocationContext writeContext(int size)
-
-