Class AbstractDelegatingAdvancedCache<K,V>
- java.lang.Object
-
- org.infinispan.cache.impl.AbstractDelegatingCache<K,V>
-
- org.infinispan.cache.impl.AbstractDelegatingAdvancedCache<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
- Direct Known Subclasses:
AbstractDelegatingAdvancedCache
,DecoratedCache
,EncoderCache
public class AbstractDelegatingAdvancedCache<K,V> extends AbstractDelegatingCache<K,V> implements AdvancedCache<K,V>
Similar toAbstractDelegatingCache
, but forAdvancedCache
.- Author:
- Mircea.Markus@jboss.com, Tristan Tarrant
- See Also:
AbstractDelegatingCache
-
-
Field Summary
Fields Modifier and Type Field Description protected AdvancedCache<K,V>
cache
-
Constructor Summary
Constructors Modifier Constructor Description AbstractDelegatingAdvancedCache(AdvancedCache<K,V> cache)
protected
AbstractDelegatingAdvancedCache(AdvancedCache<K,V> cache, AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V> wrapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInterceptor(CommandInterceptor i, int position)
Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain is at position 0 and the last one at NUM_INTERCEPTORS - 1.boolean
addInterceptorAfter(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor)
Adds a custom interceptor to the interceptor chain, after an instance of the specified interceptor type.boolean
addInterceptorBefore(CommandInterceptor i, Class<? extends CommandInterceptor> beforeInterceptor)
Adds a custom interceptor to the interceptor chain, before an instance of the specified interceptor type.void
applyDelta(K deltaAwareValueKey, Delta delta, Object... locksToAcquire)
Applies the given Delta to the DeltaAware object stored under deltaAwareValueKey if and only if all locksToAcquire locks are successfully obtainedCacheSet<CacheEntry<K,V>>
cacheEntrySet()
Identical toCache.entrySet()
but is typed to return CacheEntries instead of Entries.V
compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
An overloaded form of#compute(K, BiFunction)
, which takes in an instance ofMetadata
which 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)
.CompletableFuture<V>
computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit)
.CompletableFuture<V>
computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)
.CompletableFuture<V>
computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
Overloaded#computeAsync(K, BiFunction)
, which stores metadata alongside the value.V
computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)
An overloaded form of#computeIfAbsent(K, Function)
, which takes in an instance ofMetadata
which 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)
.CompletableFuture<V>
computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit)
Asynchronous version ofBasicCache.computeIfAbsent(Object, Function, long, TimeUnit)
.CompletableFuture<V>
computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Asynchronous version ofBasicCache.computeIfAbsent(Object, Function, long, TimeUnit, long, TimeUnit)
.CompletableFuture<V>
computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)
Overloaded#computeIfAbsentAsync(K, Function)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.V
computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
An overloaded form of#computeIfPresent(K, BiFunction)
, which takes in an instance ofMetadata
which 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)
.CompletableFuture<V>
computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
Asynchronous version ofBasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit)
.CompletableFuture<V>
computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Asynchronous version ofBasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit, long, TimeUnit)
.CompletableFuture<V>
computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
Overloaded#computeIfPresentAsync(K, BiFunction)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.AdvancedCache<K,V>
getAdvancedCache()
Map<K,V>
getAll(Set<?> keys)
Gets a collection of entries, returning them asMap
of 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 asMap
of the cache entries associated with the set of keys requested.Map<K,V>
getAndPutAll(Map<? extends K,? extends V> map)
Executes an equivalent ofMap.putAll(Map)
, returning previous values of the modified entries.AsyncInterceptorChain
getAsyncInterceptorChain()
Allows the modification of the interceptor chain.AuthorizationManager
getAuthorizationManager()
Retrieves theAuthorizationManager
if the cache has security enabled.AvailabilityMode
getAvailability()
Returns the cache's availability.BatchContainer
getBatchContainer()
Returns the component in charge of batching cache operations.String
getCacheAvailability()
CacheEntry<K,V>
getCacheEntry(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.ClassLoader
getClassLoader()
Returns the cache loader associated associated with this cache.ComponentRegistry
getComponentRegistry()
DataContainer<K,V>
getDataContainer()
Returns the container where data is stored in the cache.DistributionManager
getDistributionManager()
Retrieves a reference to theDistributionManager
if the cache is configured to use Distribution.EvictionManager
getEvictionManager()
ExpirationManager<K,V>
getExpirationManager()
Map<K,V>
getGroup(String groupName)
It fetches all the keys which belong to the group.List<CommandInterceptor>
getInterceptorChain()
InvocationContextContainer
getInvocationContextContainer()
Returns the component in charge of managing the interactions between the cache operations and the context information associated with them.DataConversion
getKeyDataConversion()
org.infinispan.commons.dataconversion.Encoder
getKeyEncoder()
org.infinispan.commons.dataconversion.Wrapper
getKeyWrapper()
LockManager
getLockManager()
Returns the component that deals with all aspects of acquiring and releasing locks for cache entries.RpcManager
getRpcManager()
Returns the component in charge of communication with other caches in the cluster.Stats
getStats()
Returns aStats
object that allows several statistics associated with this cache at runtime.TransactionManager
getTransactionManager()
DataConversion
getValueDataConversion()
org.infinispan.commons.dataconversion.Encoder
getValueEncoder()
org.infinispan.commons.dataconversion.Wrapper
getValueWrapper()
XAResource
getXAResource()
Returns theXAResource
associated with this cache which can be used to do transactional recovery.boolean
isRebalancingEnabled()
boolean
lock(Collection<? extends K> keys)
Locks collections of keys eagerly across cache nodes in a cluster.boolean
lock(K... key)
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.V
merge(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 ofMetadata
which 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)
.CompletableFuture<V>
mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
Asynchronous version ofBasicCache.merge(Object, Object, BiFunction, long, TimeUnit)
.CompletableFuture<V>
mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Asynchronous version ofBasicCache.merge(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)
.CompletableFuture<V>
mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)
OverloadedAsyncCache.mergeAsync(Object, Object, BiFunction)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.AdvancedCache<K,V>
noFlags()
Unset all flags set on this cache usingAdvancedCache.withFlags(Flag...)
orAdvancedCache.withFlags(Collection)
methods.V
put(K key, V value, Metadata metadata)
An overloaded form of#put(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.void
putAll(Map<? extends K,? extends V> map, Metadata metadata)
An overloaded form ofMap.putAll(Map)
, which takes in an instance ofMetadata
which 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> map, Metadata metadata)
CompletableFuture<V>
putAsync(K key, V value, Metadata metadata)
Asynchronous version ofAdvancedCache.put(Object, Object, Metadata)
which stores metadata alongside the value.protected void
putForExternalRead(K key, V value, EnumSet<Flag> flags, ClassLoader classLoader)
void
putForExternalRead(K key, V value, Metadata metadata)
An overloaded form of#putForExternalRead(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.protected void
putForExternalRead(K key, V value, Metadata metadata, EnumSet<Flag> flags, ClassLoader classLoader)
V
putIfAbsent(K key, V value, Metadata metadata)
An overloaded form of#putIfAbsent(K, V)
, which takes in an instance ofMetadata
which 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, Metadata metadata)
An overloaded form of#putIfAbsentAsync(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.void
removeGroup(String groupName)
It removes all the key which belongs to a group.void
removeInterceptor(int position)
Removes the interceptor at a specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.void
removeInterceptor(Class<? extends CommandInterceptor> interceptorType)
Removes the interceptor of specified type.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.V
replace(K key, V value, Metadata metadata)
An overloaded form of#replace(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.boolean
replace(K key, V oldValue, V value, Metadata metadata)
An overloaded form of#replace(K, V, V)
, which takes in an instance ofMetadata
which 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, Metadata metadata)
An overloaded form of#replaceAsync(K, V)
, which takes in an instance ofMetadata
which 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, Metadata metadata)
void
setAvailability(AvailabilityMode availabilityMode)
Manually change the availability of the cache.void
setCacheAvailability(String availabilityString)
void
setRebalancingEnabled(boolean enabled)
AdvancedCache<K,V>
transform(Function<AdvancedCache<K,V>,? extends AdvancedCache<K,V>> transformation)
Apply thetransformation
on eachAdvancedCache
instance in a delegation chain, starting with the innermost implementation.AdvancedCache<K,V>
with(ClassLoader classLoader)
Using this operation, users can call anyAdvancedCache
operation with a givenClassLoader
.AdvancedCache<K,V>
withEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> encoder)
Performs any cache operations using the specifiedEncoder
.AdvancedCache<K,V>
withEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> keyEncoder, Class<? extends org.infinispan.commons.dataconversion.Encoder> valueEncoder)
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>
withKeyEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> encoder)
AdvancedCache<K,V>
withMediaType(String keyMediaType, String valueMediaType)
Perform any cache operations using an alternateMediaType
.AdvancedCache<K,V>
withSubject(Subject subject)
Performs any cache operations using the specifiedSubject
.AdvancedCache<K,V>
withWrapping(Class<? extends org.infinispan.commons.dataconversion.Wrapper> wrapper)
Performs any cache operations using the specifiedWrapper
.AdvancedCache<K,V>
withWrapping(Class<? extends org.infinispan.commons.dataconversion.Wrapper> keyWrapper, Class<? extends org.infinispan.commons.dataconversion.Wrapper> valueWrapper)
Performs any cache operations using the specified pair ofWrapper
.-
Methods inherited from class org.infinispan.cache.impl.AbstractDelegatingCache
addFilteredListener, addListener, addListener, addListener, addStorageFormatFilteredListener, clear, clearAsync, compute, compute, compute, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, computeIfPresent, containsKey, containsValue, endBatch, entrySet, evict, forEach, get, getAsync, getCacheConfiguration, getCacheManager, getCacheName, getCacheStatus, getConfigurationAsProperties, getDelegate, getListeners, getName, getOrDefault, getStatus, getVersion, isEmpty, keySet, merge, merge, merge, put, put, put, putAll, putAll, putAll, putAllAsync, putAllAsync, putAllAsync, putAsync, putAsync, putAsync, putForExternalRead, putForExternalRead, putForExternalRead, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, remove, remove, removeAsync, removeAsync, removeListener, replace, replace, replace, replace, replace, replace, replaceAll, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, set, shutdown, size, start, startBatch, stop, toString, unwrapCache, values
-
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.AsyncCache
clearAsync, containsKeyAsync, getAsync, putAllAsync, putAllAsync, putAllAsync, putAsync, putAsync, putAsync, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync
-
Methods inherited from interface org.infinispan.commons.api.BasicCache
compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getName, getVersion, merge, merge, put, put, put, putAll, putAll, putIfAbsent, putIfAbsent, remove, replace, replace, replace, replace
-
Methods inherited from interface org.infinispan.Cache
clear, compute, compute, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, entrySet, evict, getCacheConfiguration, getCacheManager, getStatus, keySet, merge, merge, putForExternalRead, putForExternalRead, putForExternalRead, shutdown, size, stop, values
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
forEach, getOrDefault, putIfAbsent, remove, replace, replace, replaceAll
-
Methods inherited from interface org.infinispan.notifications.FilteringListenable
addFilteredListener, addListener, addListener, addStorageFormatFilteredListener
-
Methods inherited from interface org.infinispan.notifications.Listenable
addListener, getListeners, removeListener
-
Methods inherited from interface java.util.Map
containsKey, containsValue, equals, get, hashCode, isEmpty, putAll
-
-
-
-
Field Detail
-
cache
protected final AdvancedCache<K,V> cache
-
-
Constructor Detail
-
AbstractDelegatingAdvancedCache
public AbstractDelegatingAdvancedCache(AdvancedCache<K,V> cache)
-
AbstractDelegatingAdvancedCache
protected AbstractDelegatingAdvancedCache(AdvancedCache<K,V> cache, AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V> wrapper)
-
-
Method Detail
-
addInterceptor
public void addInterceptor(CommandInterceptor i, int position)
Description copied from interface:AdvancedCache
Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain is at position 0 and the last one at NUM_INTERCEPTORS - 1.- Specified by:
addInterceptor
in interfaceAdvancedCache<K,V>
- Parameters:
i
- the interceptor to addposition
- the position to add the interceptor
-
getAsyncInterceptorChain
public AsyncInterceptorChain getAsyncInterceptorChain()
Description copied from interface:AdvancedCache
Allows the modification of the interceptor chain.Experimental: The ability to modify the interceptors at runtime may be removed in future versions.
- Specified by:
getAsyncInterceptorChain
in interfaceAdvancedCache<K,V>
-
addInterceptorAfter
public boolean addInterceptorAfter(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor)
Description copied from interface:AdvancedCache
Adds a custom interceptor to the interceptor chain, after an instance of the specified interceptor type. Throws a cache exception if it cannot find an interceptor of the specified type.- Specified by:
addInterceptorAfter
in interfaceAdvancedCache<K,V>
- Parameters:
i
- interceptor to addafterInterceptor
- interceptor type after which to place custom interceptor- Returns:
- true if successful, false otherwise.
-
addInterceptorBefore
public boolean addInterceptorBefore(CommandInterceptor i, Class<? extends CommandInterceptor> beforeInterceptor)
Description copied from interface:AdvancedCache
Adds a custom interceptor to the interceptor chain, before an instance of the specified interceptor type. Throws a cache exception if it cannot find an interceptor of the specified type.- Specified by:
addInterceptorBefore
in interfaceAdvancedCache<K,V>
- Parameters:
i
- interceptor to addbeforeInterceptor
- interceptor type before which to place custom interceptor- Returns:
- true if successful, false otherwise.
-
removeInterceptor
public void removeInterceptor(int position)
Description copied from interface:AdvancedCache
Removes the interceptor at a specified position, where the first interceptor in the chain is at position 0 and the last one at getInterceptorChain().size() - 1.- Specified by:
removeInterceptor
in interfaceAdvancedCache<K,V>
- Parameters:
position
- the position at which to remove an interceptor
-
removeInterceptor
public void removeInterceptor(Class<? extends CommandInterceptor> interceptorType)
Description copied from interface:AdvancedCache
Removes the interceptor of specified type.- Specified by:
removeInterceptor
in interfaceAdvancedCache<K,V>
- Parameters:
interceptorType
- type of interceptor to remove
-
getAdvancedCache
public AdvancedCache<K,V> getAdvancedCache()
- Specified by:
getAdvancedCache
in interfaceCache<K,V>
- Overrides:
getAdvancedCache
in classAbstractDelegatingCache<K,V>
-
getInterceptorChain
public List<CommandInterceptor> getInterceptorChain()
- Specified by:
getInterceptorChain
in interfaceAdvancedCache<K,V>
-
getEvictionManager
public EvictionManager getEvictionManager()
- Specified by:
getEvictionManager
in interfaceAdvancedCache<K,V>
- Returns:
- the eviction manager - if one is configured - for this cache instance
-
getExpirationManager
public ExpirationManager<K,V> getExpirationManager()
- Specified by:
getExpirationManager
in interfaceAdvancedCache<K,V>
- Returns:
- the expiration manager - if one is configured - for this cache instance
-
getComponentRegistry
public ComponentRegistry getComponentRegistry()
- Specified by:
getComponentRegistry
in interfaceAdvancedCache<K,V>
- Returns:
- the component registry for this cache instance
-
getDistributionManager
public DistributionManager getDistributionManager()
Description copied from interface:AdvancedCache
Retrieves a reference to theDistributionManager
if the cache is configured to use Distribution. Otherwise, returns a null.- Specified by:
getDistributionManager
in interfaceAdvancedCache<K,V>
- Returns:
- a DistributionManager, or null.
-
getAuthorizationManager
public AuthorizationManager getAuthorizationManager()
Description copied from interface:AdvancedCache
Retrieves theAuthorizationManager
if the cache has security enabled. Otherwise returns null- Specified by:
getAuthorizationManager
in interfaceAdvancedCache<K,V>
- Returns:
- an AuthorizationManager or null
-
lockAs
public AdvancedCache<K,V> lockAs(Object lockOwner)
Description copied from interface:AdvancedCache
Whenever 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:
lockAs
in interfaceAdvancedCache<K,V>
- Parameters:
lockOwner
- the lock owner to lock any keys as- Returns:
- an
AdvancedCache
instance on which when an operation is invoked it will use lock owner object to acquire any locks
-
getRpcManager
public RpcManager getRpcManager()
Description copied from interface:AdvancedCache
Returns the component in charge of communication with other caches in the cluster. If the cache'sClusteringConfiguration.cacheMode()
isCacheMode.LOCAL
, this method will return null.- Specified by:
getRpcManager
in interfaceAdvancedCache<K,V>
- Returns:
- the RPC manager component associated with this cache instance or null
-
getBatchContainer
public BatchContainer getBatchContainer()
Description copied from interface:AdvancedCache
Returns the component in charge of batching cache operations.- Specified by:
getBatchContainer
in interfaceAdvancedCache<K,V>
- Returns:
- the batching component associated with this cache instance
-
getInvocationContextContainer
public InvocationContextContainer getInvocationContextContainer()
Description copied from interface:AdvancedCache
Returns the component in charge of managing the interactions between the cache operations and the context information associated with them.- Specified by:
getInvocationContextContainer
in interfaceAdvancedCache<K,V>
- Returns:
- the invocation context container component
-
getDataContainer
public DataContainer<K,V> getDataContainer()
Description copied from interface:AdvancedCache
Returns the container where data is stored in the cache. Users should interact with this component with care because direct calls on it bypass the internal interceptors and other infrastructure in place to guarantee the consistency of data.- Specified by:
getDataContainer
in interfaceAdvancedCache<K,V>
- Returns:
- the data container associated with this cache instance
-
getTransactionManager
public TransactionManager getTransactionManager()
- Specified by:
getTransactionManager
in interfaceorg.infinispan.commons.api.TransactionalCache
- Returns:
- the
TransactionManager
in use by this cache ornull
if the cache isn't transactional.
-
getLockManager
public LockManager getLockManager()
Description copied from interface:AdvancedCache
Returns the component that deals with all aspects of acquiring and releasing locks for cache entries.- Specified by:
getLockManager
in interfaceAdvancedCache<K,V>
- Returns:
- retrieves the lock manager associated with this cache instance
-
getXAResource
public XAResource getXAResource()
Description copied from interface:AdvancedCache
Returns theXAResource
associated with this cache which can be used to do transactional recovery.- Specified by:
getXAResource
in interfaceAdvancedCache<K,V>
- Returns:
- an instance of
XAResource
-
getAvailability
public AvailabilityMode getAvailability()
Description copied from interface:AdvancedCache
Returns the cache's availability. In local mode this method will always returnAvailabilityMode.AVAILABLE
. In clustered mode, thePartitionHandlingManager
is queried to obtain the availability mode.- Specified by:
getAvailability
in interfaceAdvancedCache<K,V>
-
setAvailability
public void setAvailability(AvailabilityMode availabilityMode)
Description copied from interface:AdvancedCache
Manually change the availability of the cache. Doesn't change anything if the cache is not clustered oris set to {@link org.infinispan.partitionhandling.PartitionHandling#ALLOW_READ_WRITES }
- Specified by:
setAvailability
in interfaceAdvancedCache<K,V>
-
getCacheAvailability
public String getCacheAvailability()
-
setCacheAvailability
public void setCacheAvailability(String availabilityString) throws Exception
- Throws:
Exception
-
isRebalancingEnabled
public boolean isRebalancingEnabled()
-
setRebalancingEnabled
public void setRebalancingEnabled(boolean enabled)
-
withFlags
public AdvancedCache<K,V> withFlags(Flag... flags)
Description copied from interface:AdvancedCache
A 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 theDecoratedCache
wrapper, 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:
withFlags
in interfaceAdvancedCache<K,V>
- Parameters:
flags
- a set of flags to apply. See theFlag
documentation.- Returns:
- an
AdvancedCache
instance 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:AdvancedCache
An alternative toAdvancedCache.withFlags(Flag...)
not requiring array allocation.- Specified by:
withFlags
in interfaceAdvancedCache<K,V>
- Returns:
-
noFlags
public AdvancedCache<K,V> noFlags()
Description copied from interface:AdvancedCache
Unset all flags set on this cache usingAdvancedCache.withFlags(Flag...)
orAdvancedCache.withFlags(Collection)
methods.- Specified by:
noFlags
in interfaceAdvancedCache<K,V>
- Returns:
- Cache not applying any flags to the command; possibly
this
.
-
transform
public AdvancedCache<K,V> transform(Function<AdvancedCache<K,V>,? extends AdvancedCache<K,V>> transformation)
Description copied from interface:AdvancedCache
Apply thetransformation
on eachAdvancedCache
instance in a delegation chain, starting with the innermost implementation.- Specified by:
transform
in interfaceAdvancedCache<K,V>
- Returns:
- The outermost transformed cache.
-
withSubject
public AdvancedCache<K,V> withSubject(Subject subject)
Description copied from interface:AdvancedCache
Performs any cache operations using the specifiedSubject
. Only applies to caches with authorization enabled (seeConfigurationBuilder.security()
).- Specified by:
withSubject
in interfaceAdvancedCache<K,V>
- Returns:
- an
AdvancedCache
instance on which a real operation is to be invoked, using the specified subject
-
lock
public boolean lock(K... key)
Description copied from interface:AdvancedCache
Locks 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:
lock
in interfaceAdvancedCache<K,V>
- Parameters:
key
- 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:AdvancedCache
Locks 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:
lock
in interfaceAdvancedCache<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
.
-
applyDelta
public void applyDelta(K deltaAwareValueKey, Delta delta, Object... locksToAcquire)
Description copied from interface:AdvancedCache
Applies the given Delta to the DeltaAware object stored under deltaAwareValueKey if and only if all locksToAcquire locks are successfully obtained- Specified by:
applyDelta
in interfaceAdvancedCache<K,V>
- Parameters:
deltaAwareValueKey
- the key for DeltaAware objectdelta
- the delta to be applied to DeltaAware objectlocksToAcquire
- keys to be locked in DeltaAware scope. Must contain only single key equal todeltaAwareValueKey
-
getStats
public Stats getStats()
Description copied from interface:AdvancedCache
Returns aStats
object that allows several statistics associated with this cache at runtime.- Specified by:
getStats
in interfaceAdvancedCache<K,V>
- Returns:
- this cache's
Stats
object
-
getClassLoader
public ClassLoader getClassLoader()
Description copied from interface:AdvancedCache
Returns the cache loader associated associated with this cache. As an alternative to setting this on every invocation, users could also consider using theDecoratedCache
wrapper.- Specified by:
getClassLoader
in interfaceAdvancedCache<K,V>
- Returns:
- this cache's cache loader
-
with
public AdvancedCache<K,V> with(ClassLoader classLoader)
Description copied from interface:AdvancedCache
Using this operation, users can call anyAdvancedCache
operation with a givenClassLoader
. This means that anyClassLoader
happening as a result of the cache operation will be done using theClassLoader
given. 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 theDecoratedCache
wrapper, 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:
with
in interfaceAdvancedCache<K,V>
- Returns:
- an
AdvancedCache
instance upon which operations can be called with a particularClassLoader
.
-
getAll
public Map<K,V> getAll(Set<?> keys)
Description copied from interface:AdvancedCache
Gets a collection of entries, returning them asMap
of 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
CacheLoader
is 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
Map
will 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:
getAll
in interfaceAdvancedCache<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.
-
getCacheEntry
public CacheEntry<K,V> getCacheEntry(Object key)
Description copied from interface:AdvancedCache
Retrieves a CacheEntry corresponding to a specific key.- Specified by:
getCacheEntry
in interfaceAdvancedCache<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
null
if this map contains no mapping for the key
-
getCacheEntryAsync
public CompletableFuture<CacheEntry<K,V>> getCacheEntryAsync(Object key)
Description copied from interface:AdvancedCache
Retrieves a CacheEntry corresponding to a specific key.- Specified by:
getCacheEntryAsync
in interfaceAdvancedCache<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
null
if this map contains no mapping for the key
-
getAllCacheEntries
public Map<K,CacheEntry<K,V>> getAllCacheEntries(Set<?> keys)
Description copied from interface:AdvancedCache
Gets a collection of entries from theAdvancedCache
, returning them asMap
of 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
CacheLoader
is 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
Map
will 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:
getAllCacheEntries
in interfaceAdvancedCache<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.
-
getAndPutAll
public Map<K,V> getAndPutAll(Map<? extends K,? extends V> map)
Description copied from interface:AdvancedCache
Executes an equivalent ofMap.putAll(Map)
, returning previous values of the modified entries.- Specified by:
getAndPutAll
in interfaceAdvancedCache<K,V>
- Parameters:
map
- mappings to be stored in this map- Returns:
- A map of previous values for the given keys. If the previous mapping does not exist it will not be in the returned map.
-
getGroup
public Map<K,V> getGroup(String groupName)
Description copied from interface:AdvancedCache
It 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). Themap
returned 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 theflag
Flag.SKIP_CACHE_LOAD
to avoid fetching the key/value from persistence. However, you will get an inconsistent snapshot of the group.- Specified by:
getGroup
in interfaceAdvancedCache<K,V>
- Parameters:
groupName
- the group name.- Returns:
- an immutable
Map
with the key/value pairs.
-
removeGroup
public void removeGroup(String groupName)
Description copied from interface:AdvancedCache
It 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:
removeGroup
in interfaceAdvancedCache<K,V>
- Parameters:
groupName
- the group name.
-
put
public V put(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form of#put(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.- Specified by:
put
in interfaceAdvancedCache<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.
-
replace
public V replace(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form of#replace(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
replace
in interfaceAdvancedCache<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.
-
replaceAsync
public CompletableFuture<V> replaceAsync(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form of#replaceAsync(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
replaceAsync
in interfaceAdvancedCache<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.
-
replace
public boolean replace(K key, V oldValue, V value, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form of#replace(K, V, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
replace
in interfaceAdvancedCache<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
-
replaceAsync
public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, Metadata metadata)
- Specified by:
replaceAsync
in interfaceAdvancedCache<K,V>
-
putIfAbsent
public V putIfAbsent(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form of#putIfAbsent(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
putIfAbsent
in interfaceAdvancedCache<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.
-
putIfAbsentAsync
public CompletableFuture<V> putIfAbsentAsync(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form of#putIfAbsentAsync(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
putIfAbsentAsync
in interfaceAdvancedCache<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.
-
putAsync
public CompletableFuture<V> putAsync(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCache
Asynchronous 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:
putAsync
in interfaceAdvancedCache<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.
-
putForExternalRead
public void putForExternalRead(K key, V value, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form of#putForExternalRead(K, V)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
putForExternalRead
in interfaceAdvancedCache<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
-
compute
public V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form of#compute(K, BiFunction)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.- Specified by:
compute
in interfaceAdvancedCache<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:AdvancedCache
An overloaded form of#computeIfPresent(K, BiFunction)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
computeIfPresent
in interfaceAdvancedCache<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:AdvancedCache
An overloaded form of#computeIfAbsent(K, Function)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
computeIfAbsent
in interfaceAdvancedCache<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:AdvancedCache
An overloaded form ofCache.merge(Object, Object, BiFunction)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
merge
in interfaceAdvancedCache<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
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
Description copied from interface:AdvancedCache
Overloaded#computeAsync(K, BiFunction)
, which stores metadata alongside the value. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsync
in interfaceAdvancedCache<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.
-
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
Description copied from interface:AdvancedCache
Overloaded#computeIfPresentAsync(K, BiFunction)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
computeIfPresentAsync
in interfaceAdvancedCache<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.
-
computeIfAbsentAsync
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)
Description copied from interface:AdvancedCache
Overloaded#computeIfAbsentAsync(K, Function)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
computeIfAbsentAsync
in interfaceAdvancedCache<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.
-
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.merge(Object, Object, BiFunction, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
mergeAsync
in interfaceAdvancedCache<K,V>
- Specified by:
mergeAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
mergeAsync
in classAbstractDelegatingCache<K,V>
- Parameters:
key
- key to usevalue
- new value to merge with existing valueremappingFunction
- function to use to merge new and existing values into a merged value to store under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the merged value that was stored under key
-
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.merge(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
mergeAsync
in interfaceAdvancedCache<K,V>
- Specified by:
mergeAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
mergeAsync
in classAbstractDelegatingCache<K,V>
- Parameters:
key
- key to usevalue
- new value to merge with existing valueremappingFunction
- function to use to merge new and existing values into a merged value to store under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the merged value that was stored under key
-
mergeAsync
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)
Description copied from interface:AdvancedCache
OverloadedAsyncCache.mergeAsync(Object, Object, BiFunction)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. TheMetadata
is only stored if the call is successful.- Specified by:
mergeAsync
in interfaceAdvancedCache<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
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofConcurrentMap.compute(Object, BiFunction)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeAsync
in classAbstractDelegatingCache<K,V>
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeAsync
in classAbstractDelegatingCache<K,V>
-
computeAsync
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeAsync
in classAbstractDelegatingCache<K,V>
-
computeIfAbsentAsync
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofConcurrentMap.computeIfAbsent(Object, Function)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfAbsentAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeIfAbsentAsync
in classAbstractDelegatingCache<K,V>
-
computeIfAbsentAsync
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.computeIfAbsent(Object, Function, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfAbsentAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeIfAbsentAsync
in classAbstractDelegatingCache<K,V>
-
computeIfAbsentAsync
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.computeIfAbsent(Object, Function, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfAbsentAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeIfAbsentAsync
in classAbstractDelegatingCache<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.AsyncCache
Asynchronous version ofConcurrentMap.computeIfPresent(Object, BiFunction)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfPresentAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeIfPresentAsync
in classAbstractDelegatingCache<K,V>
-
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfPresentAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeIfPresentAsync
in classAbstractDelegatingCache<K,V>
-
computeIfPresentAsync
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
computeIfPresentAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
computeIfPresentAsync
in classAbstractDelegatingCache<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.AsyncCache
Asynchronous version ofConcurrentMap.merge(Object, Object, BiFunction)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
mergeAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
mergeAsync
in classAbstractDelegatingCache<K,V>
-
putAll
public void putAll(Map<? extends K,? extends V> map, Metadata metadata)
Description copied from interface:AdvancedCache
An overloaded form ofMap.putAll(Map)
, which takes in an instance ofMetadata
which can be used to provide metadata information for the entries being stored, such as lifespan, version of value...etc.- Specified by:
putAll
in interfaceAdvancedCache<K,V>
- Parameters:
map
- the values to storemetadata
- information to store alongside the value(s)
-
putAllAsync
public CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> map, Metadata metadata)
- Specified by:
putAllAsync
in interfaceAdvancedCache<K,V>
-
cacheEntrySet
public CacheSet<CacheEntry<K,V>> cacheEntrySet()
Description copied from interface:AdvancedCache
Identical 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:
cacheEntrySet
in interfaceAdvancedCache<K,V>
- Returns:
- the entry set containing all of the CacheEntries
- See Also:
Cache.entrySet()
-
lockedStream
public LockedStream<K,V> lockedStream()
Description copied from interface:AdvancedCache
Returns a sequential stream using this Cache as the source. This stream is very similar to using theCacheStream
returned 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:
lockedStream
in interfaceAdvancedCache<K,V>
- Returns:
- the locked stream
-
removeLifespanExpired
public CompletableFuture<Boolean> removeLifespanExpired(K key, V value, Long lifespan)
Description copied from interface:AdvancedCache
Attempts 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:
removeLifespanExpired
in interfaceAdvancedCache<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:AdvancedCache
Attempts 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:
removeMaxIdleExpired
in interfaceAdvancedCache<K,V>
- Parameters:
key
- the key that expired via max idle for the given entry- Returns:
- if the entry was removed
-
withEncoding
public AdvancedCache<K,V> withEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> encoder)
Description copied from interface:AdvancedCache
Performs any cache operations using the specifiedEncoder
.- Specified by:
withEncoding
in interfaceAdvancedCache<K,V>
- Parameters:
encoder
-Encoder
used for both keys and values.- Returns:
- an instance of
AdvancedCache
where all operations will use the supplied encoder.
-
withEncoding
public AdvancedCache<K,V> withEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> keyEncoder, Class<? extends org.infinispan.commons.dataconversion.Encoder> valueEncoder)
Description copied from interface:AdvancedCache
Performs any cache operations using the specified pair ofEncoder
.- Specified by:
withEncoding
in interfaceAdvancedCache<K,V>
- Parameters:
keyEncoder
-Encoder
for the keys.valueEncoder
-Encoder
for the values.- Returns:
- an instance of
AdvancedCache
where all operations will use the supplied encoders.
-
withKeyEncoding
public AdvancedCache<K,V> withKeyEncoding(Class<? extends org.infinispan.commons.dataconversion.Encoder> encoder)
- Specified by:
withKeyEncoding
in interfaceAdvancedCache<K,V>
-
withWrapping
public AdvancedCache<K,V> withWrapping(Class<? extends org.infinispan.commons.dataconversion.Wrapper> wrapper)
Description copied from interface:AdvancedCache
Performs any cache operations using the specifiedWrapper
.- Specified by:
withWrapping
in interfaceAdvancedCache<K,V>
- Parameters:
wrapper
-Wrapper
for the keys and values.- Returns:
- an instance of
AdvancedCache
where all operations will use the supplied wrapper.
-
withMediaType
public AdvancedCache<K,V> withMediaType(String keyMediaType, String valueMediaType)
Description copied from interface:AdvancedCache
Perform any cache operations using an alternateMediaType
.- Specified by:
withMediaType
in interfaceAdvancedCache<K,V>
- Parameters:
keyMediaType
-MediaType
for the keys.valueMediaType
-org.infinispan.commons.dataconversion
for the values.- Returns:
- an instance of
AdvancedCache
where all data will formatted according to the suppliedMediaType
.
-
withWrapping
public AdvancedCache<K,V> withWrapping(Class<? extends org.infinispan.commons.dataconversion.Wrapper> keyWrapper, Class<? extends org.infinispan.commons.dataconversion.Wrapper> valueWrapper)
Description copied from interface:AdvancedCache
Performs any cache operations using the specified pair ofWrapper
.- Specified by:
withWrapping
in interfaceAdvancedCache<K,V>
- Parameters:
keyWrapper
-Wrapper
for the keys.valueWrapper
-Wrapper
for the values.- Returns:
AdvancedCache
where all operations will use the supplied wrappers.
-
getKeyEncoder
public org.infinispan.commons.dataconversion.Encoder getKeyEncoder()
- Specified by:
getKeyEncoder
in interfaceAdvancedCache<K,V>
- Returns:
- The associated
Encoder
for the keys.
-
getValueEncoder
public org.infinispan.commons.dataconversion.Encoder getValueEncoder()
- Specified by:
getValueEncoder
in interfaceAdvancedCache<K,V>
- Returns:
- The associated
Encoder
for the cache's values.
-
getKeyWrapper
public org.infinispan.commons.dataconversion.Wrapper getKeyWrapper()
- Specified by:
getKeyWrapper
in interfaceAdvancedCache<K,V>
- Returns:
- The associated
Wrapper
for the cache's keys.
-
getValueWrapper
public org.infinispan.commons.dataconversion.Wrapper getValueWrapper()
- Specified by:
getValueWrapper
in interfaceAdvancedCache<K,V>
- Returns:
- The associated
Wrapper
for the cache's values.
-
getKeyDataConversion
public DataConversion getKeyDataConversion()
- Specified by:
getKeyDataConversion
in interfaceAdvancedCache<K,V>
- Returns:
- The associated
DataConversion
for the keys.
-
getValueDataConversion
public DataConversion getValueDataConversion()
- Specified by:
getValueDataConversion
in interfaceAdvancedCache<K,V>
- Returns:
- The associated
DataConversion
for the cache's values.
-
putForExternalRead
protected final void putForExternalRead(K key, V value, EnumSet<Flag> flags, ClassLoader classLoader)
-
putForExternalRead
protected final void putForExternalRead(K key, V value, Metadata metadata, EnumSet<Flag> flags, ClassLoader classLoader)
-
getAllAsync
public CompletableFuture<Map<K,V>> getAllAsync(Set<?> keys)
- Specified by:
getAllAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Overrides:
getAllAsync
in classAbstractDelegatingCache<K,V>
-
-