public interface AdvancedCache<K,V> extends Cache<K,V>
Cache
.Modifier and Type | Method and Description |
---|---|
void |
addInterceptor(CommandInterceptor i,
int position)
Deprecated.
Since 9.0, use
getAsyncInterceptorChain() instead. |
boolean |
addInterceptorAfter(CommandInterceptor i,
Class<? extends CommandInterceptor> afterInterceptor)
Deprecated.
Since 9.0, use
getAsyncInterceptorChain() instead. |
boolean |
addInterceptorBefore(CommandInterceptor i,
Class<? extends CommandInterceptor> beforeInterceptor)
Deprecated.
Since 9.0, use
getAsyncInterceptorChain() instead. |
void |
applyDelta(K deltaAwareValueKey,
Delta delta,
Object... locksToAcquire)
Deprecated.
since 9.1
|
CacheSet<CacheEntry<K,V>> |
cacheEntrySet()
Identical to
Cache.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 of Metadata which can be
used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. |
default V |
compute(K key,
SerializableBiFunction<? super K,? super V,? extends V> remappingFunction,
Metadata metadata)
Overloaded
compute(Object, BiFunction, Metadata) with SerializableBiFunction |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction,
Metadata metadata)
An overloaded form of
#computeIfAbsent(K, Function) , which takes in an instance of Metadata which
can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. |
default V |
computeIfAbsent(K key,
SerializableFunction<? super K,? extends V> mappingFunction,
Metadata metadata)
Overloaded
computeIfAbsent(Object, Function, Metadata) with SerializableFunction |
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 of Metadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of
value...etc. |
default V |
computeIfPresent(K key,
SerializableBiFunction<? super K,? super V,? extends V> remappingFunction,
Metadata metadata)
Overloaded
computeIfPresent(Object, BiFunction, Metadata) with SerializableBiFunction |
Map<K,V> |
getAll(Set<?> keys)
Gets a collection of entries, returning them as
Map of the values associated with the set of keys
requested. |
Map<K,CacheEntry<K,V>> |
getAllCacheEntries(Set<?> keys)
Gets a collection of entries from the
AdvancedCache , returning them as Map of the cache entries
associated with the set of keys requested. |
default Map<K,V> |
getAndPutAll(Map<? extends K,? extends V> map)
Executes an equivalent of
Map.putAll(Map) , returning previous values of the modified entries. |
AsyncInterceptorChain |
getAsyncInterceptorChain()
Allows the modification of the interceptor chain.
|
AuthorizationManager |
getAuthorizationManager()
Retrieves the
AuthorizationManager if the cache has security enabled. |
AvailabilityMode |
getAvailability()
Returns the cache's availability.
|
BatchContainer |
getBatchContainer()
Returns the component in charge of batching cache operations.
|
CacheEntry<K,V> |
getCacheEntry(Object key)
Retrieves a CacheEntry corresponding to a specific key.
|
default 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 the
DistributionManager 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()
Deprecated.
Since 9.0, use
getAsyncInterceptorChain() instead. |
InvocationContextContainer |
getInvocationContextContainer()
Deprecated.
No longer in use, implementations might return null.
|
DataConversion |
getKeyDataConversion() |
Encoder |
getKeyEncoder()
Deprecated.
Use
getKeyDataConversion() and then DataConversion.getEncoder() |
Wrapper |
getKeyWrapper()
Deprecated.
Use
getKeyDataConversion() and then DataConversion.getWrapper() |
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 a
Stats object that allows several statistics associated with this cache at runtime. |
TransactionManager |
getTransactionManager()
Returns the transaction manager configured for this cache.
|
DataConversion |
getValueDataConversion() |
Encoder |
getValueEncoder()
Deprecated.
Use
getValueDataConversion() ()} and then DataConversion.getEncoder() |
Wrapper |
getValueWrapper()
Deprecated.
Use
getValueDataConversion() ()} and then DataConversion.getWrapper() |
XAResource |
getXAResource()
Returns the
XAResource associated with this cache which can be used to do transactional recovery. |
boolean |
lock(Collection<? extends K> keys)
Locks collections of keys eagerly across cache nodes in a cluster.
|
boolean |
lock(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.
|
V |
merge(K key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction,
Metadata metadata)
An overloaded form of
Cache.merge(Object, Object, BiFunction) , which takes in an instance of Metadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of
value...etc. |
default V |
merge(K key,
V value,
SerializableBiFunction<? super V,? super V,? extends V> remappingFunction,
Metadata metadata)
Overloaded
merge(Object, Object, BiFunction, Metadata) with SerializableBiFunction |
default AdvancedCache<K,V> |
noFlags()
Unset all flags set on this cache using
withFlags(Flag...) or withFlags(Collection) methods. |
V |
put(K key,
V value,
Metadata metadata)
An overloaded form of
#put(K, V) , which takes in an instance of Metadata
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 of
Map.putAll(Map) , which takes in an instance of Metadata
which can be used to provide metadata information for the entries being stored, such as lifespan, version of
value...etc. |
default CompletableFuture<Void> |
putAllAsync(Map<? extends K,? extends V> map,
Metadata metadata) |
CompletableFuture<V> |
putAsync(K key,
V value,
Metadata metadata)
Asynchronous version of
put(Object, Object, Metadata) which stores metadata alongside the value. |
void |
putForExternalRead(K key,
V value,
Metadata metadata)
An overloaded form of
#putForExternalRead(K, V) , which takes in an instance of Metadata which can
be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. |
V |
putIfAbsent(K key,
V value,
Metadata metadata)
An overloaded form of
#putIfAbsent(K, V) , which takes in an instance of Metadata which can be used
to provide metadata information for the entry being stored, such as lifespan, version of value...etc. |
default CompletableFuture<V> |
putIfAbsentAsync(K key,
V value,
Metadata metadata)
An overloaded form of
#putIfAbsentAsync(K, V) , which takes in an instance of Metadata which can be used
to provide metadata information for the entry being stored, such as lifespan, version of value...etc. |
void |
removeExpired(K key,
V value,
Long lifespan)
Attempts to remove the entry if it is expired.
|
void |
removeGroup(String groupName)
It removes all the key which belongs to a group.
|
void |
removeInterceptor(Class<? extends CommandInterceptor> interceptorType)
Deprecated.
Since 9.0, use
getAsyncInterceptorChain() instead. |
void |
removeInterceptor(int position)
Deprecated.
Since 9.0, use
getAsyncInterceptorChain() instead. |
V |
replace(K key,
V value,
Metadata metadata)
An overloaded form of
#replace(K, V) , which takes in an instance of Metadata 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 newValue,
Metadata metadata)
An overloaded form of
#replace(K, V, V) , which takes in an instance of Metadata which can be used
to provide metadata information for the entry being stored, such as lifespan, version of value...etc. |
default CompletableFuture<V> |
replaceAsync(K key,
V value,
Metadata metadata)
An overloaded form of
#replaceAsync(K, V) , which takes in an instance of Metadata which can be used to
provide metadata information for the entry being stored, such as lifespan, version of value...etc. |
default CompletableFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
Metadata metadata) |
void |
setAvailability(AvailabilityMode availabilityMode)
Manually change the availability of the cache.
|
default AdvancedCache<K,V> |
transform(Function<AdvancedCache<K,V>,? extends AdvancedCache<K,V>> transformation)
Apply the
transformation on each AdvancedCache instance in a delegation chain, starting
with the innermost implementation. |
AdvancedCache<K,V> |
with(ClassLoader classLoader)
Deprecated.
A cache manager, and all caches within it, can only have one classloader associated to it, so it's no
longer possible to read cached data with a different classloader.
|
AdvancedCache<?,?> |
withEncoding(Class<? extends Encoder> encoder)
Performs any cache operations using the specified
Encoder . |
AdvancedCache<?,?> |
withEncoding(Class<? extends Encoder> keyEncoder,
Class<? extends Encoder> valueEncoder)
Performs any cache operations using the specified pair of
Encoder . |
default AdvancedCache<K,V> |
withFlags(Collection<Flag> flags)
An alternative to
withFlags(Flag...) not requiring array allocation. |
AdvancedCache<K,V> |
withFlags(Flag... flags)
A method that adds flags to any API call.
|
AdvancedCache<?,?> |
withKeyEncoding(Class<? extends Encoder> encoder) |
AdvancedCache<?,?> |
withMediaType(String keyMediaType,
String valueMediaType)
Perform any cache operations using an alternate
MediaType . |
AdvancedCache<K,V> |
withSubject(Subject subject)
Performs any cache operations using the specified
Subject . |
AdvancedCache<K,V> |
withWrapping(Class<? extends Wrapper> wrapper)
Performs any cache operations using the specified
Wrapper . |
AdvancedCache<K,V> |
withWrapping(Class<? extends Wrapper> keyWrapper,
Class<? extends Wrapper> valueWrapper)
Performs any cache operations using the specified pair of
Wrapper . |
clear, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, entrySet, evict, getAdvancedCache, getCacheConfiguration, getCacheManager, getStatus, keySet, merge, merge, putForExternalRead, putForExternalRead, putForExternalRead, shutdown, size, stop, values
getName, getVersion, merge, merge, put, put, put, putAll, putAll, putIfAbsent, putIfAbsent, remove, replace, replace, replace, replace
clearAsync, containsKeyAsync, getAllAsync, getAsync, putAllAsync, putAllAsync, putAllAsync, putAsync, putAsync, putAsync, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync
forEach, getOrDefault, putIfAbsent, remove, replace, replace, replaceAll
containsKey, containsValue, equals, get, hashCode, isEmpty, putAll
endBatch, startBatch
addFilteredListener, addListener, addListener
addListener, getListeners, removeListener
AdvancedCache<K,V> withFlags(Flag... flags)
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 the
DecoratedCache
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);
flags
- a set of flags to apply. See the Flag
documentation.AdvancedCache
instance on which a real operation is to be invoked, if the flags are to be
applied.default AdvancedCache<K,V> withFlags(Collection<Flag> flags)
withFlags(Flag...)
not requiring array allocation.flags
- default AdvancedCache<K,V> noFlags()
withFlags(Flag...)
or withFlags(Collection)
methods.this
.default AdvancedCache<K,V> transform(Function<AdvancedCache<K,V>,? extends AdvancedCache<K,V>> transformation)
transformation
on each AdvancedCache
instance in a delegation chain, starting
with the innermost implementation.transformation
- AdvancedCache<K,V> withSubject(Subject subject)
Subject
. Only applies to caches with authorization
enabled (see ConfigurationBuilder.security()
).subject
- AdvancedCache
instance on which a real operation is to be invoked, using the specified subject@Deprecated void addInterceptor(CommandInterceptor i, int position)
getAsyncInterceptorChain()
instead.i
- the interceptor to addposition
- the position to add the interceptor@Deprecated boolean addInterceptorAfter(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor)
getAsyncInterceptorChain()
instead.i
- interceptor to addafterInterceptor
- interceptor type after which to place custom interceptor@Deprecated boolean addInterceptorBefore(CommandInterceptor i, Class<? extends CommandInterceptor> beforeInterceptor)
getAsyncInterceptorChain()
instead.i
- interceptor to addbeforeInterceptor
- interceptor type before which to place custom interceptor@Deprecated void removeInterceptor(int position)
getAsyncInterceptorChain()
instead.position
- the position at which to remove an interceptor@Deprecated void removeInterceptor(Class<? extends CommandInterceptor> interceptorType)
getAsyncInterceptorChain()
instead.interceptorType
- type of interceptor to remove@Deprecated List<CommandInterceptor> getInterceptorChain()
getAsyncInterceptorChain()
instead.AsyncInterceptorChain getAsyncInterceptorChain()
Experimental: The ability to modify the interceptors at runtime may be removed in future versions.
EvictionManager getEvictionManager()
ExpirationManager<K,V> getExpirationManager()
ComponentRegistry getComponentRegistry()
DistributionManager getDistributionManager()
DistributionManager
if the cache is configured to
use Distribution. Otherwise, returns a null.AuthorizationManager getAuthorizationManager()
AuthorizationManager
if the cache has security enabled. Otherwise returns nullAdvancedCache<K,V> lockAs(Object lockOwner)
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.
lockOwner
- the lock owner to lock any keys asAdvancedCache
instance on which when an operation is invoked it will use lock owner object to
acquire any locksboolean lock(K... keys)
Keys can be locked eagerly in the context of a transaction only.
keys
- the keys to lockFlag.FAIL_SILENTLY
.TimeoutException
- if the lock cannot be acquired within the configured lock
acquisition time.boolean lock(Collection<? extends K> keys)
Collections of keys can be locked eagerly in the context of a transaction only.
keys
- collection of keys to lockFlag.FAIL_SILENTLY
.TimeoutException
- if the lock cannot be acquired within the configured lock
acquisition time.@Deprecated void applyDelta(K deltaAwareValueKey, Delta delta, Object... locksToAcquire)
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 to
deltaAwareValueKey
RpcManager getRpcManager()
ClusteringConfiguration.cacheMode()
is CacheMode.LOCAL
, this method will return null.BatchContainer getBatchContainer()
@Deprecated InvocationContextContainer getInvocationContextContainer()
DataContainer<K,V> getDataContainer()
TransactionManager getTransactionManager()
LockManager getLockManager()
Stats getStats()
Stats
object that allows several statistics associated with this cache at runtime.Stats
objectXAResource getXAResource()
XAResource
associated with this cache which can be used to do transactional recovery.XAResource
ClassLoader getClassLoader()
DecoratedCache
wrapper.@Deprecated AdvancedCache<K,V> with(ClassLoader classLoader)
AdvancedCache
operation with a given ClassLoader
. This
means that any ClassLoader
happening as a result of the cache operation will be done using the ClassLoader
given. For example:
When users store POJO instances in caches configured with StoreAsBinaryConfiguration
,
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. Using 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 the
DecoratedCache
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);
AdvancedCache
instance upon which operations can be called with a particular ClassLoader
.V put(K key, V value, Metadata metadata)
#put(K, V)
, which takes in an instance of Metadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of
value...etc.key
- key to usevalue
- value to storemetadata
- information to store alongside the valuevoid putAll(Map<? extends K,? extends V> map, Metadata metadata)
Map.putAll(Map)
, which takes in an instance of Metadata
which can be used to provide metadata information for the entries being stored, such as lifespan, version of
value...etc.map
- the values to storemetadata
- information to store alongside the value(s)default CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> map, Metadata metadata)
V replace(K key, V value, Metadata metadata)
#replace(K, V)
, which takes in an instance of Metadata
which can be used to
provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata
is only stored if the call is successful.key
- key with which the specified value is associatedvalue
- value to be associated with the specified keymetadata
- information to store alongside the new valuedefault CompletableFuture<V> replaceAsync(K key, V value, Metadata metadata)
#replaceAsync(K, V)
, which takes in an instance of Metadata
which can be used to
provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata
is only stored if the call is successful.key
- key with which the specified value is associatedvalue
- value to be associated with the specified keymetadata
- information to store alongside the new valueboolean replace(K key, V oldValue, V newValue, Metadata metadata)
#replace(K, V, V)
, which takes in an instance of Metadata
which can be used
to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata
is only stored if the call is successful.key
- key with which the specified value is associatedoldValue
- value expected to be associated with the specified keynewValue
- value to be associated with the specified keymetadata
- information to store alongside the new valuedefault CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, Metadata metadata)
V putIfAbsent(K key, V value, Metadata metadata)
#putIfAbsent(K, V)
, which takes in an instance of Metadata
which can be used
to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata
is only stored if the call is successful.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 valuedefault CompletableFuture<V> putIfAbsentAsync(K key, V value, Metadata metadata)
#putIfAbsentAsync(K, V)
, which takes in an instance of Metadata
which can be used
to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The Metadata
is only stored if the call is successful.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 valuevoid putForExternalRead(K key, V value, Metadata metadata)
#putForExternalRead(K, V)
, which takes in an instance of Metadata
which can
be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc. The
Metadata
is only stored if the call is successful.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 valueV compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
#compute(K, BiFunction)
, which takes in an instance of Metadata
which can be
used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.key
- key with which the specified value is associatedremappingFunction
- function to be applied to the specified key/valuemetadata
- information to store alongside the new valuedefault V compute(K key, SerializableBiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
compute(Object, BiFunction, Metadata)
with SerializableBiFunction
V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
#computeIfPresent(K, BiFunction)
, which takes in an instance of Metadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of
value...etc. The Metadata
is only stored if the call is successful.key
- key with which the specified value is associatedremappingFunction
- function to be applied to the specified key/valuemetadata
- information to store alongside the new valuedefault V computeIfPresent(K key, SerializableBiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
computeIfPresent(Object, BiFunction, Metadata)
with SerializableBiFunction
V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)
#computeIfAbsent(K, Function)
, which takes in an instance of Metadata
which
can be used to provide metadata information for the entry being stored, such as lifespan, version of value...etc.
The Metadata
is only stored if the call is successful.key
- key with which the specified value is associatedmappingFunction
- function to be applied to the specified keymetadata
- information to store alongside the new valuedefault V computeIfAbsent(K key, SerializableFunction<? super K,? extends V> mappingFunction, Metadata metadata)
computeIfAbsent(Object, Function, Metadata)
with SerializableFunction
V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)
Cache.merge(Object, Object, BiFunction)
, which takes in an instance of Metadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of
value...etc. The Metadata
is only stored if the call is successful.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 valuedefault V merge(K key, V value, SerializableBiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)
merge(Object, Object, BiFunction, Metadata)
with SerializableBiFunction
CompletableFuture<V> putAsync(K key, V value, Metadata metadata)
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 over put(Object, Object, Metadata)
if used in LOCAL mode.
key
- key to usevalue
- value to storemetadata
- information to store alongside the new valueMap<K,V> getAll(Set<?> keys)
Map
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.
keys
- The keys whose associated values are to be returned.NullPointerException
- if keys is null or if keys contains a nullCacheEntry<K,V> getCacheEntry(Object key)
key
- the key whose associated cache entry is to be returnednull
if this map contains no mapping for
the keydefault CompletableFuture<CacheEntry<K,V>> getCacheEntryAsync(Object key)
key
- the key whose associated cache entry is to be returnednull
if this map contains no mapping for the keyMap<K,CacheEntry<K,V>> getAllCacheEntries(Set<?> keys)
AdvancedCache
, returning them as Map
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.
keys
- The keys whose associated values are to be returned.NullPointerException
- if keys is null or if keys contains a nulldefault Map<K,V> getAndPutAll(Map<? extends K,? extends V> map)
Map.putAll(Map)
, returning previous values of the modified entries.map
- mappings to be stored in this mapMap<K,V> getGroup(String groupName)
map
returned is immutable and represents the group at the time of the invocation. If you want to add
or remove keys from a group use BasicCache.put(Object, Object)
and BasicCache.remove(Object)
. To remove all the keys
in the group use removeGroup(String)
.
To improve performance you may use the flag
Flag.SKIP_CACHE_LOAD
to avoid
fetching the key/value from persistence. However, you will get an inconsistent snapshot of the group.groupName
- the group name.Map
with the key/value pairs.void removeGroup(String groupName)
groupName
- the group name.AvailabilityMode getAvailability()
AvailabilityMode.AVAILABLE
.
In clustered mode, the PartitionHandlingManager
is queried to obtain the availability mode.void setAvailability(AvailabilityMode availabilityMode)
CacheSet<CacheEntry<K,V>> cacheEntrySet()
Cache.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
Cache.entrySet()
LockedStream<K,V> lockedStream()
CacheStream
returned from the CacheCollection.stream()
method of the collection returned via 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 to LockingMode.OPTIMISTIC
, do not support this method. In this case it will throw an UnsupportedOperationException
. 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 via lockAs(Object)
as this could
lead to a deadlock or the release of locks early and will throw an IllegalStateException
.
UnsupportedOperationException
- this is thrown if invoked from a cache that doesn't support thisIllegalStateException
- if this cache has already explicitly set a lock ownervoid removeExpired(K key, V value, Long lifespan)
ExpirationManager
.
This command will only remove the value if the value and lifespan also match if provided.
NOTE: This method may be removed at any point including in a minor release and is not supported for external usage.
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 valueAdvancedCache<?,?> withEncoding(Class<? extends Encoder> keyEncoder, Class<? extends Encoder> valueEncoder)
Encoder
.keyEncoder
- Encoder
for the keys.valueEncoder
- Encoder
for the values.AdvancedCache
where all operations will use the supplied encoders.AdvancedCache<K,V> withWrapping(Class<? extends Wrapper> keyWrapper, Class<? extends Wrapper> valueWrapper)
Wrapper
.keyWrapper
- Wrapper
for the keys.valueWrapper
- Wrapper
for the values.AdvancedCache
where all operations will use the supplied wrappers.AdvancedCache<?,?> withEncoding(Class<? extends Encoder> encoder)
Encoder
.encoder
- Encoder
used for both keys and values.AdvancedCache
where all operations will use the supplied encoder.AdvancedCache<K,V> withWrapping(Class<? extends Wrapper> wrapper)
Wrapper
.wrapper
- Wrapper
for the keys and values.AdvancedCache
where all operations will use the supplied wrapper.AdvancedCache<?,?> withMediaType(String keyMediaType, String valueMediaType)
MediaType
.keyMediaType
- MediaType
for the keys.valueMediaType
- org.infinispan.commons.dataconversion
for the values.AdvancedCache
where all data will formatted according to the supplied MediaType
.Encoder getKeyEncoder()
getKeyDataConversion()
and then DataConversion.getEncoder()
Encoder
for the keys.Encoder getValueEncoder()
getValueDataConversion()
()} and then DataConversion.getEncoder()
Encoder
for the cache's values.Wrapper getKeyWrapper()
getKeyDataConversion()
and then DataConversion.getWrapper()
Wrapper
for the cache's keys.Wrapper getValueWrapper()
getValueDataConversion()
()} and then DataConversion.getWrapper()
Wrapper
for the cache's values.DataConversion getKeyDataConversion()
DataConversion
for the keys.DataConversion getValueDataConversion()
DataConversion
for the cache's values.AdvancedCache<?,?> withKeyEncoding(Class<? extends Encoder> encoder)
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.