public final class SecureCacheImpl<K,V> extends Object implements SecureCache<K,V>
Constructor and Description |
---|
SecureCacheImpl(AdvancedCache<K,V> delegate) |
Modifier and Type | Method and Description |
---|---|
<C> CompletionStage<Void> |
addFilteredListenerAsync(Object listener,
CacheEventFilter<? super K,? super V> filter,
CacheEventConverter<? super K,? super V,C> converter,
Set<Class<? extends Annotation>> filterAnnotations)
Asynchronous version of
FilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set) |
CompletionStage<Void> |
addListenerAsync(Object listener)
Asynchronous version of
Listenable.addListener(Object) |
<C> CompletionStage<Void> |
addListenerAsync(Object listener,
CacheEventFilter<? super K,? super V> filter,
CacheEventConverter<? super K,? super V,C> converter)
Asynchronous version of
FilteringListenable.addListener(Object, CacheEventFilter, CacheEventConverter) |
<C> CompletionStage<Void> |
addStorageFormatFilteredListenerAsync(Object listener,
CacheEventFilter<? super K,? super V> filter,
CacheEventConverter<? super K,? super V,C> converter,
Set<Class<? extends Annotation>> filterAnnotations)
|
CacheSet<CacheEntry<K,V>> |
cacheEntrySet()
Identical to
Cache.entrySet() but is typed to return CacheEntries instead of Entries. |
void |
clear()
Removes all mappings from the cache.
|
CompletableFuture<Void> |
clearAsync()
Asynchronous version of
Map.clear() . |
V |
compute(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction) |
V |
compute(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
long lifespan,
TimeUnit lifespanUnit)
An overloaded form of
ConcurrentMap.compute(Object, BiFunction) which takes in lifespan parameters. |
V |
compute(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
ConcurrentMap.compute(Object, BiFunction) which takes in lifespan and maxIdleTime parameters. |
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. |
CompletableFuture<V> |
computeAsync(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction)
Asynchronous version of
ConcurrentMap.compute(Object, BiFunction) . |
CompletableFuture<V> |
computeAsync(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
long lifespan,
TimeUnit lifespanUnit)
Asynchronous version of
BasicCache.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 of
BasicCache.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) |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction,
long lifespan,
TimeUnit lifespanUnit)
An overloaded form of
ConcurrentMap.computeIfAbsent(Object, Function) which takes in lifespan parameters. |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
ConcurrentMap.computeIfAbsent(Object, Function) which takes in lifespan and maxIdleTime parameters. |
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. |
CompletableFuture<V> |
computeIfAbsentAsync(K key,
Function<? super K,? extends V> mappingFunction)
Asynchronous version of
ConcurrentMap.computeIfAbsent(Object, Function) . |
CompletableFuture<V> |
computeIfAbsentAsync(K key,
Function<? super K,? extends V> mappingFunction,
long lifespan,
TimeUnit lifespanUnit)
Asynchronous version of
BasicCache.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 of
BasicCache.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 of Metadata 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) |
V |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
long lifespan,
TimeUnit lifespanUnit)
An overloaded form of
ConcurrentMap.computeIfPresent(Object, BiFunction) which takes in lifespan parameters. |
V |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
ConcurrentMap.computeIfPresent(Object, BiFunction) which takes in lifespan and maxIdleTime parameters. |
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. |
CompletableFuture<V> |
computeIfPresentAsync(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction)
Asynchronous version of
ConcurrentMap.computeIfPresent(Object, BiFunction) . |
CompletableFuture<V> |
computeIfPresentAsync(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction,
long lifespan,
TimeUnit lifespanUnit)
Asynchronous version of
BasicCache.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 of
BasicCache.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 of Metadata
which can be used to provide metadata information for the entry being stored, such as lifespan, version of
value...etc. |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
void |
endBatch(boolean successful)
Completes a batch if one has been started using
BatchingCache.startBatch() . |
CacheSet<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this cache and cache loader across the entire cluster.
|
boolean |
equals(Object o) |
void |
evict(K key)
Evicts an entry from the memory of the cache.
|
V |
get(Object key) |
AdvancedCache<K,V> |
getAdvancedCache() |
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. |
CompletableFuture<Map<K,V>> |
getAllAsync(Set<?> keys)
TODO This should be in AdvancedCache with getAll
|
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. |
Map<K,V> |
getAndPutAll(Map<? extends K,? extends V> map)
Executes an equivalent of
Map.putAll(Map) , returning previous values of the modified entries. |
CompletableFuture<V> |
getAsync(K key)
Asynchronous version of
Map.get(Object) that allows user code to
retrieve the value associated with a key at a later stage, hence allowing
multiple parallel get requests to be sent. |
AsyncInterceptorChain |
getAsyncInterceptorChain()
Deprecated.
Since 10.0, will be removed without a replacement
|
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.
|
Configuration |
getCacheConfiguration() |
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.
|
EmbeddedCacheManager |
getCacheManager()
Retrieves the cache manager responsible for creating this cache instance.
|
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.
|
AdvancedCache<K,V> |
getDelegate() |
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.
|
DataConversion |
getKeyDataConversion() |
Set<Object> |
getListeners()
Deprecated.
|
LockManager |
getLockManager()
Returns the component that deals with all aspects of acquiring and releasing locks for cache entries.
|
String |
getName()
Retrieves the name of the cache
|
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. |
ComponentStatus |
getStatus() |
TransactionManager |
getTransactionManager() |
DataConversion |
getValueDataConversion() |
String |
getVersion()
Retrieves the version of Infinispan
|
XAResource |
getXAResource()
Returns the
XAResource associated with this cache which can be used to do transactional recovery. |
int |
hashCode() |
boolean |
isEmpty() |
CacheSet<K> |
keySet()
Returns a set view of the keys contained in this cache and cache loader across the entire cluster.
|
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) |
V |
merge(K key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction,
long lifespan,
TimeUnit lifespanUnit)
An overloaded form of
ConcurrentMap.merge(Object, Object, BiFunction) which takes in lifespan parameters. |
V |
merge(K key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
ConcurrentMap.merge(Object, Object, BiFunction) which takes in lifespan parameters. |
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. |
CompletableFuture<V> |
mergeAsync(K key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction)
Asynchronous version of
ConcurrentMap.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 of
BasicCache.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 of
BasicCache.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)
Overloaded
AsyncCache.mergeAsync(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. |
AdvancedCache<K,V> |
noFlags()
Unset all flags set on this cache using
AdvancedCache.withFlags(Flag...) or AdvancedCache.withFlags(Collection) methods. |
V |
put(K key,
V value)
If the return value of this operation will be ignored by the application,
the user is strongly encouraged to use the
Flag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently
as possible (i.e. |
V |
put(K key,
V value,
long lifespan,
TimeUnit unit)
An overloaded form of
BasicCache.put(Object, Object) , which takes in lifespan parameters. |
V |
put(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
BasicCache.put(Object, Object) , which takes in lifespan parameters. |
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> m) |
void |
putAll(Map<? extends K,? extends V> map,
long lifespan,
TimeUnit unit)
An overloaded form of
Map.putAll(Map) , which takes in lifespan parameters. |
void |
putAll(Map<? extends K,? extends V> map,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
Map.putAll(Map) , which takes in lifespan parameters. |
void |
putAll(Map<? extends K,? extends V> m,
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. |
CompletableFuture<Void> |
putAllAsync(Map<? extends K,? extends V> data)
Asynchronous version of
Map.putAll(Map) . |
CompletableFuture<Void> |
putAllAsync(Map<? extends K,? extends V> data,
long lifespan,
TimeUnit unit)
Asynchronous version of
BasicCache.putAll(Map, long, TimeUnit) . |
CompletableFuture<Void> |
putAllAsync(Map<? extends K,? extends V> data,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit)
Asynchronous version of
BasicCache.putAll(Map, long, TimeUnit, long, TimeUnit) . |
CompletableFuture<Void> |
putAllAsync(Map<? extends K,? extends V> map,
Metadata metadata) |
CompletableFuture<V> |
putAsync(K key,
V value)
Asynchronous version of
BasicCache.put(Object, Object) . |
CompletableFuture<V> |
putAsync(K key,
V value,
long lifespan,
TimeUnit unit)
Asynchronous version of
BasicCache.put(Object, Object, long, TimeUnit) . |
CompletableFuture<V> |
putAsync(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit)
Asynchronous version of
BasicCache.put(Object, Object, long, TimeUnit, long, TimeUnit) . |
CompletableFuture<V> |
putAsync(K key,
V value,
Metadata metadata)
Asynchronous version of
AdvancedCache.put(Object, Object, Metadata) which stores metadata alongside the value. |
void |
putForExternalRead(K key,
V value)
Under special operating behavior, associates the value with the specified key.
|
void |
putForExternalRead(K key,
V value,
long lifespan,
TimeUnit unit)
An overloaded form of
#putForExternalRead(K, V) , which takes in lifespan parameters. |
void |
putForExternalRead(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit)
An overloaded form of
#putForExternalRead(K, V) , which takes in lifespan parameters. |
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) |
V |
putIfAbsent(K key,
V value,
long lifespan,
TimeUnit unit)
An overloaded form of
ConcurrentMap.putIfAbsent(Object, Object) , which takes in lifespan parameters. |
V |
putIfAbsent(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
ConcurrentMap.putIfAbsent(Object, Object) , which takes in lifespan parameters. |
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. |
CompletableFuture<V> |
putIfAbsentAsync(K key,
V value)
Asynchronous version of
ConcurrentMap.putIfAbsent(Object, Object) . |
CompletableFuture<V> |
putIfAbsentAsync(K key,
V value,
long lifespan,
TimeUnit unit)
Asynchronous version of
BasicCache.putIfAbsent(Object, Object, long, TimeUnit) . |
CompletableFuture<V> |
putIfAbsentAsync(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit)
Asynchronous version of
BasicCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit) . |
CompletableFuture<V> |
putIfAbsentAsync(K key,
V value,
Metadata metadata)
An overloaded form of
#putIfAbsentAsync(K, V) , which takes in an instance of Metadata which can be used
to provide metadata information for the entry being stored, such as lifespan, version of value...etc. |
V |
remove(Object key)
If the return value of this operation will be ignored by the application,
the user is strongly encouraged to use the
Flag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently
as possible (i.e. |
boolean |
remove(Object key,
Object value) |
CompletableFuture<V> |
removeAsync(Object key)
Asynchronous version of
BasicCache.remove(Object) . |
CompletableFuture<Boolean> |
removeAsync(Object key,
Object value)
Asynchronous version of
ConcurrentMap.remove(Object, Object) . |
void |
removeGroup(String groupName)
It removes all the key which belongs to a group.
|
CompletableFuture<Boolean> |
removeLifespanExpired(K key,
V value,
Long lifespan)
Attempts to remove the entry if it is expired.
|
CompletionStage<Void> |
removeListenerAsync(Object listener)
Asynchronous version of
Listenable.removeListener(Object) |
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) |
V |
replace(K key,
V value,
long lifespan,
TimeUnit unit)
An overloaded form of
ConcurrentMap.replace(Object, Object) , which takes in lifespan parameters. |
V |
replace(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
ConcurrentMap.replace(Object, Object) , which takes in lifespan parameters. |
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) |
boolean |
replace(K key,
V oldValue,
V value,
long lifespan,
TimeUnit unit)
An overloaded form of
ConcurrentMap.replace(Object, Object, Object) , which takes in lifespan parameters. |
boolean |
replace(K key,
V oldValue,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit)
An overloaded form of
ConcurrentMap.replace(Object, Object, Object) , which takes in lifespan parameters. |
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. |
CompletableFuture<V> |
replaceAsync(K key,
V value)
Asynchronous version of
ConcurrentMap.replace(Object, Object) . |
CompletableFuture<V> |
replaceAsync(K key,
V value,
long lifespan,
TimeUnit unit)
Asynchronous version of
BasicCache.replace(Object, Object, long, TimeUnit) . |
CompletableFuture<V> |
replaceAsync(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit)
Asynchronous version of
BasicCache.replace(Object, Object, long, TimeUnit, long, TimeUnit) . |
CompletableFuture<V> |
replaceAsync(K key,
V value,
Metadata metadata)
An overloaded form of
#replaceAsync(K, V) , which takes in an instance of Metadata 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)
Asynchronous version of
ConcurrentMap.replace(Object, Object, Object) . |
CompletableFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
long lifespan,
TimeUnit unit)
Asynchronous version of
BasicCache.replace(Object, Object, Object, long, TimeUnit) . |
CompletableFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit)
Asynchronous version of
BasicCache.replace(Object, Object, Object, long, TimeUnit, long, TimeUnit) . |
CompletableFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
Metadata metadata) |
void |
setAvailability(AvailabilityMode availabilityMode)
Manually change the availability of the cache.
|
void |
shutdown()
Performs a controlled, clustered shutdown of the cache.
|
int |
size()
Returns a count of all elements in this cache and cache loader across the entire cluster.
|
CompletableFuture<Long> |
sizeAsync()
Asynchronous version of
Map.size() . |
void |
start()
Invoked on component start
|
boolean |
startBatch()
Starts a batch.
|
void |
stop()
Stops a cache.
|
String |
toString() |
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. |
CacheCollection<V> |
values()
Returns a collection view of the values contained in this cache across the entire cluster.
|
AdvancedCache<K,V> |
with(ClassLoader classLoader) |
AdvancedCache<?,?> |
withEncoding(Class<? extends Encoder> encoderClass)
Performs any cache operations using the specified
Encoder . |
AdvancedCache<?,?> |
withEncoding(Class<? extends Encoder> keyEncoderClass,
Class<? extends Encoder> valueEncoderClass)
Performs any cache operations using the specified pair of
Encoder . |
AdvancedCache<K,V> |
withFlags(Collection<Flag> flags)
An alternative to
AdvancedCache.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> |
withStorageMediaType()
Perform any cache operations using the same
MediaType of the cache
storage. |
AdvancedCache<K,V> |
withSubject(Subject subject)
Performs any cache operations using the specified
Subject . |
AdvancedCache<K,V> |
withWrapping(Class<? extends Wrapper> wrapperClass)
Performs any cache operations using the specified
Wrapper . |
AdvancedCache<K,V> |
withWrapping(Class<? extends Wrapper> keyWrapperClass,
Class<? extends Wrapper> valueWrapperClass)
Performs any cache operations using the specified pair of
Wrapper . |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeAsync, computeIfAbsent, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, merge, mergeAsync, withFlags
compute, compute, compute, computeAsync, computeAsync, computeAsync, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, merge, merge, merge, mergeAsync, mergeAsync, mergeAsync
containsKeyAsync
forEach, getOrDefault, replaceAll
addFilteredListener, addListener, addStorageFormatFilteredListener
addListener, removeListener
public SecureCacheImpl(AdvancedCache<K,V> delegate)
public AdvancedCache<K,V> getDelegate()
public AdvancedCache<K,V> withSubject(Subject subject)
AdvancedCache
Subject
. Only applies to caches with authorization
enabled (see ConfigurationBuilder.security()
).withSubject
in interface AdvancedCache<K,V>
AdvancedCache
instance on which a real operation is to be invoked, using the specified subjectpublic boolean startBatch()
BatchingCache
startBatch
in interface BatchingCache
public <C> CompletionStage<Void> addListenerAsync(Object listener, CacheEventFilter<? super K,? super V> filter, CacheEventConverter<? super K,? super V,C> converter)
FilteringListenable
FilteringListenable.addListener(Object, CacheEventFilter, CacheEventConverter)
addListenerAsync
in interface FilteringListenable<K,V>
listener
- listener to add, must not be nullpublic CompletionStage<Void> addListenerAsync(Object listener)
Listenable
Listenable.addListener(Object)
addListenerAsync
in interface Listenable
listener
- listener to add, must not be nullpublic <C> CompletionStage<Void> addFilteredListenerAsync(Object listener, CacheEventFilter<? super K,? super V> filter, CacheEventConverter<? super K,? super V,C> converter, Set<Class<? extends Annotation>> filterAnnotations)
FilteringListenable
FilteringListenable.addFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)
addFilteredListenerAsync
in interface FilteringListenable<K,V>
public <C> CompletionStage<Void> addStorageFormatFilteredListenerAsync(Object listener, CacheEventFilter<? super K,? super V> filter, CacheEventConverter<? super K,? super V,C> converter, Set<Class<? extends Annotation>> filterAnnotations)
FilteringListenable
FilteringListenable.addStorageFormatFilteredListener(Object, CacheEventFilter, CacheEventConverter, Set)
addStorageFormatFilteredListenerAsync
in interface FilteringListenable<K,V>
public void shutdown()
Cache
GlobalStateConfigurationBuilder.persistentLocation(String)
Cache.stop()
only in clustered modes,
and only when GlobalStateConfiguration.enabled()
is true, otherwise it
just behaves like Cache.stop()
.public void start()
Lifecycle
public void stop()
Cache
Cache.shutdown()
method.public CompletableFuture<V> putAsync(K key, V value)
AsyncCache
BasicCache.put(Object, Object)
. This method does not block on remote calls, even if your
cache mode is synchronous.putAsync
in interface AsyncCache<K,V>
key
- key to usevalue
- value to storepublic void endBatch(boolean successful)
BatchingCache
BatchingCache.startBatch()
. If no batch has been started, this is a
no-op.
endBatch
in interface BatchingCache
successful
- if true, the batch completes, otherwise the batch is aborted and changes are not committed.public CompletionStage<Void> removeListenerAsync(Object listener)
Listenable
Listenable.removeListener(Object)
removeListenerAsync
in interface Listenable
listener
- listener to remove, must not be null@Deprecated public Set<Object> getListeners()
getListeners
in interface Listenable
public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit unit)
AsyncCache
BasicCache.put(Object, Object, long, TimeUnit)
. This method does not block on remote
calls, even if your cache mode is synchronous.putAsync
in interface AsyncCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic AdvancedCache<K,V> withFlags(Flag... flags)
AdvancedCache
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 should also consider saving the decorated cache, as this allows for more readable code. E.g.:
AdvancedCache<?, ?> forceWriteLockCache = cache.withFlags(Flag.FORCE_WRITE_LOCK); forceWriteLockCache.get(key1); forceWriteLockCache.get(key2); forceWriteLockCache.get(key3);
withFlags
in interface AdvancedCache<K,V>
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.public AdvancedCache<K,V> withFlags(Collection<Flag> flags)
AdvancedCache
AdvancedCache.withFlags(Flag...)
not requiring array allocation.withFlags
in interface AdvancedCache<K,V>
public AdvancedCache<K,V> noFlags()
AdvancedCache
AdvancedCache.withFlags(Flag...)
or AdvancedCache.withFlags(Collection)
methods.noFlags
in interface AdvancedCache<K,V>
this
.public AdvancedCache<K,V> transform(Function<AdvancedCache<K,V>,? extends AdvancedCache<K,V>> transformation)
AdvancedCache
transformation
on each AdvancedCache
instance in a delegation chain, starting
with the innermost implementation.transform
in interface AdvancedCache<K,V>
public V putIfAbsent(K key, V value)
putIfAbsent
in interface ConcurrentMap<K,V>
putIfAbsent
in interface Map<K,V>
public CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
AsyncCache
BasicCache.put(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block
on remote calls, even if your cache mode is synchronous.putAsync
in interface AsyncCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- time unit for lifespanmaxIdle
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit
- time unit for max idle timepublic String getName()
BasicCache
getName
in interface BasicCache<K,V>
public String getVersion()
BasicCache
getVersion
in interface BasicCache<K,V>
public V put(K key, V value)
BasicCache
Flag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently
as possible (i.e. avoiding needless remote or network calls).public CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data)
AsyncCache
Map.putAll(Map)
. This method does not block on remote calls, even if your cache mode
is synchronous.putAllAsync
in interface AsyncCache<K,V>
data
- to storepublic V put(K key, V value, long lifespan, TimeUnit unit)
BasicCache
BasicCache.put(Object, Object)
, which takes in lifespan parameters.put
in interface BasicCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespanpublic CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)
AsyncCache
BasicCache.putAll(Map, long, TimeUnit)
. This method does not block on remote calls, even if
your cache mode is synchronous.putAllAsync
in interface AsyncCache<K,V>
data
- to storelifespan
- lifespan of entryunit
- time unit for lifespan@Deprecated public AsyncInterceptorChain getAsyncInterceptorChain()
AdvancedCache
getAsyncInterceptorChain
in interface AdvancedCache<K,V>
public V putIfAbsent(K key, V value, long lifespan, TimeUnit unit)
BasicCache
ConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.putIfAbsent
in interface BasicCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespanpublic CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
AsyncCache
BasicCache.putAll(Map, long, TimeUnit, long, TimeUnit)
. This method does not block on
remote calls, even if your cache mode is synchronous.putAllAsync
in interface AsyncCache<K,V>
data
- to storelifespan
- lifespan of entrylifespanUnit
- time unit for lifespanmaxIdle
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit
- time unit for max idle timepublic void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
BasicCache
Map.putAll(Map)
, which takes in lifespan parameters. Note that the lifespan is applied
to all mappings in the map passed in.putAll
in interface BasicCache<K,V>
map
- map containing mappings to enterlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespanpublic CompletableFuture<Void> clearAsync()
AsyncCache
Map.clear()
. This method does not block on remote calls, even if your cache mode is
synchronous.clearAsync
in interface AsyncCache<K,V>
public V replace(K key, V value, long lifespan, TimeUnit unit)
BasicCache
ConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.replace
in interface BasicCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespanpublic CompletableFuture<V> putIfAbsentAsync(K key, V value)
AsyncCache
ConcurrentMap.putIfAbsent(Object, Object)
. This method does not block on remote calls, even if
your cache mode is synchronous.putIfAbsentAsync
in interface AsyncCache<K,V>
key
- key to usevalue
- value to storepublic boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit unit)
BasicCache
ConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.replace
in interface BasicCache<K,V>
key
- key to useoldValue
- value to replacevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespanpublic CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit)
AsyncCache
BasicCache.putIfAbsent(Object, Object, long, TimeUnit)
. This method does not block on
remote calls, even if your cache mode is synchronous.putIfAbsentAsync
in interface AsyncCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic EvictionManager getEvictionManager()
getEvictionManager
in interface AdvancedCache<K,V>
public ExpirationManager<K,V> getExpirationManager()
getExpirationManager
in interface AdvancedCache<K,V>
public V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
BasicCache.put(Object, Object)
, which takes in lifespan parameters.put
in interface BasicCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit
- time unit for max idle timepublic void putForExternalRead(K key, V value)
Cache
ConcurrentMap.putIfAbsent(Object, Object)
)
putForExternalRead
in interface Cache<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public void putForExternalRead(K key, V value, Metadata metadata)
AdvancedCache
#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.putForExternalRead
in interface AdvancedCache<K,V>
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 valuepublic V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
Cache
When this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized
to owning nodes to perform the operation in the most performant way. However this means the bifunction must
have an appropriate Externalizer
or be Serializable
itself.
For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
public V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
Cache
When this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized
to owning nodes to perform the operation in the most performant way. However this means the bifunction must
have an appropriate Externalizer
or be Serializable
itself.
For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
public V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
BasicCache
ConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.merge
in interface BasicCache<K,V>
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 lifespanpublic V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
ConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.merge
in interface BasicCache<K,V>
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 timepublic V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)
AdvancedCache
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.merge
in interface AdvancedCache<K,V>
public V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
AdvancedCache
#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.compute
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedremappingFunction
- function to be applied to the specified key/valuemetadata
- information to store alongside the new valuepublic V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
BasicCache
ConcurrentMap.compute(Object, BiFunction)
which takes in lifespan parameters.compute
in interface BasicCache<K,V>
key
- key to useremappingFunction
- function to use to compute and store the value under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanpublic V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
ConcurrentMap.compute(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.compute
in interface BasicCache<K,V>
key
- key to useremappingFunction
- function to use to compute and store the value under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit
- time unit for max idle timepublic V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
Cache
When this method is used on a clustered cache, either replicated or distributed, the bifunction will be serialized
to owning nodes to perform the operation in the most performant way. However this means the bifunction must
have an appropriate Externalizer
or be Serializable
itself.
For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
computeIfPresent
in interface ConcurrentMap<K,V>
computeIfPresent
in interface Map<K,V>
computeIfPresent
in interface Cache<K,V>
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
AdvancedCache
#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.computeIfPresent
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedremappingFunction
- function to be applied to the specified key/valuemetadata
- information to store alongside the new valuepublic V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
BasicCache
ConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan parameters.computeIfPresent
in interface BasicCache<K,V>
key
- key to useremappingFunction
- function to use to compute and store the value under key, if such existslifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanpublic V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
ConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.computeIfPresent
in interface BasicCache<K,V>
key
- key to useremappingFunction
- function to use to compute and store the value under key, if such existslifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit
- time unit for max idle timepublic V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
Cache
When this method is used on a clustered cache, either replicated or distributed, the function will be serialized
to owning nodes to perform the operation in the most performant way. However this means the function must
have an appropriate Externalizer
or be Serializable
itself.
For transactional caches, whenever the values of the caches are collections, and the mapping function modifies the collection, the collection must be copied and not directly modified, otherwise whenever rollback is called it won't work. This limitation could disappear in following releases if technically possible.
computeIfAbsent
in interface ConcurrentMap<K,V>
computeIfAbsent
in interface Map<K,V>
computeIfAbsent
in interface Cache<K,V>
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)
AdvancedCache
#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.computeIfAbsent
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedmappingFunction
- function to be applied to the specified keymetadata
- information to store alongside the new valuepublic V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit)
BasicCache
ConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan parameters.computeIfAbsent
in interface BasicCache<K,V>
key
- key to usemappingFunction
- function to use to compute and store the value under key, if the key is absentlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanpublic V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
ConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan and maxIdleTime parameters.computeIfAbsent
in interface BasicCache<K,V>
key
- key to usemappingFunction
- function to use to compute and store the value under key, if the key is absentlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit
- time unit for max idle timepublic CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
AdvancedCache
#computeAsync(K, BiFunction)
, which stores metadata alongside the value. This
method does not block on remote calls, even if your cache mode is synchronous.computeAsync
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedremappingFunction
- function to be applied to the specified key/valuemetadata
- information to store alongside the new valuepublic CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, Metadata metadata)
AdvancedCache
#computeIfPresentAsync(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.computeIfPresentAsync
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedremappingFunction
- function to be applied to the specified key/valuemetadata
- information to store alongside the new valuepublic CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, Metadata metadata)
AdvancedCache
#computeIfAbsentAsync(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.computeIfAbsentAsync
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedmappingFunction
- function to be applied to the specified keymetadata
- information to store alongside the new valuepublic CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
AsyncCache
BasicCache.merge(Object, Object, BiFunction, long, TimeUnit)
. This method does not
block on remote calls, even if your cache mode is synchronous.mergeAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
AsyncCache
BasicCache.merge(Object, Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This
method does not block on remote calls, even if your cache mode is synchronous.mergeAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, Metadata metadata)
AdvancedCache
AsyncCache.mergeAsync(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.mergeAsync
in interface AdvancedCache<K,V>
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
AsyncCache
ConcurrentMap.compute(Object, BiFunction)
. This method does not block on remote
calls, even if your cache mode is synchronous.computeAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
AsyncCache
BasicCache.compute(Object, BiFunction, long, TimeUnit)
. This method does not block on remote
calls, even if your cache mode is synchronous.computeAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
AsyncCache
BasicCache.compute(Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on remote
calls, even if your cache mode is synchronous.computeAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction)
AsyncCache
ConcurrentMap.computeIfAbsent(Object, Function)
. This method does not block on remote
calls, even if your cache mode is synchronous.computeIfAbsentAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit)
AsyncCache
BasicCache.computeIfAbsent(Object, Function, long, TimeUnit)
. This method does not block on remote
calls, even if your cache mode is synchronous.computeIfAbsentAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
AsyncCache
BasicCache.computeIfAbsent(Object, Function, long, TimeUnit, long, TimeUnit)
. This method does not block on remote
calls, even if your cache mode is synchronous.computeIfAbsentAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
AsyncCache
ConcurrentMap.computeIfPresent(Object, BiFunction)
. This method does not block on
remote calls, even if your cache mode is synchronous.computeIfPresentAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
AsyncCache
BasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit)
. This method does not block on
remote calls, even if your cache mode is synchronous.computeIfPresentAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> computeIfPresentAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
AsyncCache
BasicCache.computeIfPresent(Object, BiFunction, long, TimeUnit, long, TimeUnit)
. This method does not block on
remote calls, even if your cache mode is synchronous.computeIfPresentAsync
in interface AsyncCache<K,V>
public CompletableFuture<V> mergeAsync(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
AsyncCache
ConcurrentMap.merge(Object, Object, BiFunction)
. This method does not block on remote
calls, even if your cache mode is synchronous.mergeAsync
in interface AsyncCache<K,V>
public void putForExternalRead(K key, V value, long lifespan, TimeUnit unit)
Cache
#putForExternalRead(K, V)
, which takes in lifespan parameters.putForExternalRead
in interface Cache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespanpublic void putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Cache
#putForExternalRead(K, V)
, which takes in lifespan parameters.putForExternalRead
in interface Cache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdle
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit
- time unit for max idle timepublic ComponentRegistry getComponentRegistry()
getComponentRegistry
in interface AdvancedCache<K,V>
public DistributionManager getDistributionManager()
AdvancedCache
DistributionManager
if the cache is configured to
use Distribution. Otherwise, returns a null.getDistributionManager
in interface AdvancedCache<K,V>
public AuthorizationManager getAuthorizationManager()
AdvancedCache
AuthorizationManager
if the cache has security enabled. Otherwise returns nullgetAuthorizationManager
in interface AdvancedCache<K,V>
public AdvancedCache<K,V> lockAs(Object lockOwner)
AdvancedCache
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.
lockAs
in interface AdvancedCache<K,V>
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 lockspublic CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
AsyncCache
BasicCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does
not block on remote calls, even if your cache mode is synchronous.putIfAbsentAsync
in interface AsyncCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- time unit for lifespanmaxIdle
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit
- time unit for max idle timepublic boolean lock(K... keys)
AdvancedCache
Keys can be locked eagerly in the context of a transaction only.
lock
in interface AdvancedCache<K,V>
keys
- the keys to lockFlag.FAIL_SILENTLY
.public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
ConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.putIfAbsent
in interface BasicCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit
- time unit for max idle timepublic boolean lock(Collection<? extends K> keys)
AdvancedCache
Collections of keys can be locked eagerly in the context of a transaction only.
lock
in interface AdvancedCache<K,V>
keys
- collection of keys to lockFlag.FAIL_SILENTLY
.public CompletableFuture<V> removeAsync(Object key)
AsyncCache
BasicCache.remove(Object)
. This method does not block on remote calls, even if your cache
mode is synchronous.removeAsync
in interface AsyncCache<K,V>
key
- key to removepublic boolean containsValue(Object value)
containsValue
in interface Map<K,V>
public void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
Map.putAll(Map)
, which takes in lifespan parameters. Note that the lifespan is applied
to all mappings in the map passed in.putAll
in interface BasicCache<K,V>
map
- map containing mappings to enterlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit
- time unit for max idle timepublic CompletableFuture<Boolean> removeAsync(Object key, Object value)
AsyncCache
ConcurrentMap.remove(Object, Object)
. This method does not block on remote calls, even if your
cache mode is synchronous.removeAsync
in interface AsyncCache<K,V>
key
- key to removevalue
- value to match onpublic void evict(K key)
Cache
BasicCache.remove(Object)
to remove an
entry from the entire cache system.
This method is designed to evict an entry from memory to free up memory used by the application. This method uses
a 0 lock acquisition timeout so it does not block in attempting to acquire locks. It behaves as a no-op if the
lock on the entry cannot be acquired immediately.
Important: this method should not be called from within a transaction scope.public CompletableFuture<V> replaceAsync(K key, V value)
AsyncCache
ConcurrentMap.replace(Object, Object)
. This method does not block on remote calls, even if
your cache mode is synchronous.replaceAsync
in interface AsyncCache<K,V>
key
- key to removevalue
- value to storepublic RpcManager getRpcManager()
AdvancedCache
ClusteringConfiguration.cacheMode()
is CacheMode.LOCAL
, this method will return null.getRpcManager
in interface AdvancedCache<K,V>
public V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
ConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.replace
in interface BasicCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit
- time unit for max idle timepublic CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit unit)
AsyncCache
BasicCache.replace(Object, Object, long, TimeUnit)
. This method does not block on remote
calls, even if your cache mode is synchronous.replaceAsync
in interface AsyncCache<K,V>
key
- key to removevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic BatchContainer getBatchContainer()
AdvancedCache
getBatchContainer
in interface AdvancedCache<K,V>
public Configuration getCacheConfiguration()
getCacheConfiguration
in interface Cache<K,V>
public EmbeddedCacheManager getCacheManager()
Cache
getCacheManager
in interface Cache<K,V>
public AdvancedCache<K,V> getAdvancedCache()
getAdvancedCache
in interface Cache<K,V>
public ComponentStatus getStatus()
public AvailabilityMode getAvailability()
AdvancedCache
AvailabilityMode.AVAILABLE
.
In clustered mode, the PartitionHandlingManager
is queried to obtain the availability mode.getAvailability
in interface AdvancedCache<K,V>
public void setAvailability(AvailabilityMode availabilityMode)
AdvancedCache
PartitionHandlingConfiguration.whenSplit()
is set to PartitionHandling.ALLOW_READ_WRITES
.setAvailability
in interface AdvancedCache<K,V>
public CacheSet<CacheEntry<K,V>> cacheEntrySet()
AdvancedCache
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
cacheEntrySet
in interface AdvancedCache<K,V>
Cache.entrySet()
public LockedStream<K,V> lockedStream()
AdvancedCache
CacheStream
returned from the CacheCollection.stream()
method of the collection returned via AdvancedCache.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 AdvancedCache.lockAs(Object)
as this could
lead to a deadlock or the release of locks early and will throw an IllegalStateException
.
lockedStream
in interface AdvancedCache<K,V>
public CompletableFuture<Boolean> removeLifespanExpired(K key, V value, Long lifespan)
AdvancedCache
ExpirationManager
.
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.
removeLifespanExpired
in interface AdvancedCache<K,V>
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 valuepublic CompletableFuture<Boolean> removeMaxIdleExpired(K key, V value)
AdvancedCache
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.
removeMaxIdleExpired
in interface AdvancedCache<K,V>
key
- the key that expired via max idle for the given entrypublic AdvancedCache<?,?> withEncoding(Class<? extends Encoder> encoderClass)
AdvancedCache
Encoder
.withEncoding
in interface AdvancedCache<K,V>
encoderClass
- Encoder
used for both keys and values.AdvancedCache
where all operations will use the supplied encoder.public AdvancedCache<?,?> withKeyEncoding(Class<? extends Encoder> encoder)
withKeyEncoding
in interface AdvancedCache<K,V>
public AdvancedCache<K,V> withWrapping(Class<? extends Wrapper> wrapperClass)
AdvancedCache
Wrapper
.withWrapping
in interface AdvancedCache<K,V>
wrapperClass
- Wrapper
for the keys and values.AdvancedCache
where all operations will use the supplied wrapper.public AdvancedCache<?,?> withMediaType(String keyMediaType, String valueMediaType)
AdvancedCache
MediaType
.withMediaType
in interface AdvancedCache<K,V>
keyMediaType
- MediaType
for the keys.valueMediaType
- org.infinispan.commons.dataconversion
for the values.AdvancedCache
where all data will formatted according to the supplied MediaType
.public AdvancedCache<K,V> withStorageMediaType()
AdvancedCache
MediaType
of the cache
storage. This is equivalent to disabling transcoding on the cache.withStorageMediaType
in interface AdvancedCache<K,V>
AdvancedCache
where no data conversion will take place.public AdvancedCache<?,?> withEncoding(Class<? extends Encoder> keyEncoderClass, Class<? extends Encoder> valueEncoderClass)
AdvancedCache
Encoder
.withEncoding
in interface AdvancedCache<K,V>
keyEncoderClass
- Encoder
for the keys.valueEncoderClass
- Encoder
for the values.AdvancedCache
where all operations will use the supplied encoders.public AdvancedCache<K,V> withWrapping(Class<? extends Wrapper> keyWrapperClass, Class<? extends Wrapper> valueWrapperClass)
AdvancedCache
Wrapper
.withWrapping
in interface AdvancedCache<K,V>
keyWrapperClass
- Wrapper
for the keys.valueWrapperClass
- Wrapper
for the values.AdvancedCache
where all operations will use the supplied wrappers.public DataConversion getKeyDataConversion()
getKeyDataConversion
in interface AdvancedCache<K,V>
DataConversion
for the keys.public DataConversion getValueDataConversion()
getValueDataConversion
in interface AdvancedCache<K,V>
DataConversion
for the cache's values.public int size()
Cache
Flag.SKIP_CACHE_LOAD
flag should be used to
avoid hitting the cache loader in case if this is not needed in the size calculation.
Also if you want the local contents only you can use the Flag.CACHE_MODE_LOCAL
flag so
that other remote nodes are not queried for data. However the loader will still be used unless the previously
mentioned Flag.SKIP_CACHE_LOAD
is also configured.
If this method is used in a transactional context, note this method will not bring additional values into the
transaction context and thus objects that haven't yet been read will act in a
IsolationLevel.READ_COMMITTED
behavior irrespective of the configured
isolation level. However values that have been previously modified or read that are in the context will be
adhered to. e.g. any write modification or any previous read when using
IsolationLevel.REPEATABLE_READ
This method should only be used for debugging purposes such as to verify that the cache contains all the keys
entered. Any other use involving execution of this method on a production system is not recommended.
public CompletableFuture<Long> sizeAsync()
AsyncCache
Map.size()
. This method does not block on remote calls, even if your cache mode is
synchronous.sizeAsync
in interface AsyncCache<K,V>
public boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
BasicCache
ConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.replace
in interface BasicCache<K,V>
key
- key to useoldValue
- value to replacevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleTimeUnit
- time unit for max idle timepublic DataContainer<K,V> getDataContainer()
AdvancedCache
getDataContainer
in interface AdvancedCache<K,V>
public CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
AsyncCache
BasicCache.replace(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not
block on remote calls, even if your cache mode is synchronous.replaceAsync
in interface AsyncCache<K,V>
key
- key to removevalue
- value to storelifespan
- lifespan of entrylifespanUnit
- time unit for lifespanmaxIdle
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit
- time unit for max idle timepublic TransactionManager getTransactionManager()
getTransactionManager
in interface TransactionalCache
TransactionManager
in use by this cache or null
if the cache isn't transactional.public CacheSet<K> keySet()
Cache
Set.toArray()
, Set.toArray(Object[])
,
Set.size()
, Set.retainAll(Collection)
and Set.iterator()
methods as they will traverse the entire contents of the cluster including a configured
CacheLoader
and remote entries. The former 2 methods especially have a
very high likely hood of causing a OutOfMemoryError
due to storing all the keys in the entire
cluster in the array.
Use involving execution of this method on a production system is not recommended as they can be quite expensive
operations
Flag.SKIP_CACHE_LOAD
flag should be used to
avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to
prevent OutOfMemoryError
)
Also if you want the local contents only you can use the Flag.CACHE_MODE_LOCAL
flag so
that other remote nodes are not queried for data. However the loader will still be used unless the previously
mentioned Flag.SKIP_CACHE_LOAD
is also configured.
CloseableIteratorSet
interface which creates a
CloseableIterator
instead of a regular one. This means this iterator must be
explicitly closed either through try with resource or calling the close method directly. Technically this iterator
will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.
UnsupportedOperationException
if invoked.
Set.add(Object)
Set.addAll(java.util.Collection)
public V remove(Object key)
BasicCache
Flag.IGNORE_RETURN_VALUES
flag when invoking this method in order to make it behave as efficiently
as possible (i.e. avoiding needless remote or network calls).public Map<K,V> getAll(Set<?> keys)
AdvancedCache
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.
getAll
in interface AdvancedCache<K,V>
keys
- The keys whose associated values are to be returned.public CompletableFuture<Map<K,V>> getAllAsync(Set<?> keys)
AsyncCache
getAllAsync
in interface AsyncCache<K,V>
public LockManager getLockManager()
AdvancedCache
getLockManager
in interface AdvancedCache<K,V>
public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
AsyncCache
ConcurrentMap.replace(Object, Object, Object)
. This method does not block on remote calls,
even if your cache mode is synchronous.replaceAsync
in interface AsyncCache<K,V>
key
- key to removeoldValue
- value to overwritenewValue
- value to storepublic Stats getStats()
AdvancedCache
Stats
object that allows several statistics associated with this cache at runtime.getStats
in interface AdvancedCache<K,V>
Stats
objectpublic XAResource getXAResource()
AdvancedCache
XAResource
associated with this cache which can be used to do transactional recovery.getXAResource
in interface AdvancedCache<K,V>
XAResource
public ClassLoader getClassLoader()
AdvancedCache
DecoratedCache
wrapper.getClassLoader
in interface AdvancedCache<K,V>
public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit)
AsyncCache
BasicCache.replace(Object, Object, Object, long, TimeUnit)
. This method does not block on
remote calls, even if your cache mode is synchronous.replaceAsync
in interface AsyncCache<K,V>
key
- key to removeoldValue
- value to overwritenewValue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic CacheCollection<V> values()
Cache
Collection.toArray()
, Collection.toArray(Object[])
,
Collection.size()
, Collection.retainAll(Collection)
and Collection.iterator()
methods as they will traverse the entire contents of the cluster including a configured
CacheLoader
and remote entries. The former 2 methods especially have a
very high likely hood of causing a OutOfMemoryError
due to storing all the keys in the entire
cluster in the array.
Use involving execution of this method on a production system is not recommended as they can be quite expensive
operations
* Flag.SKIP_CACHE_LOAD
flag should be used to
avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to
prevent OutOfMemoryError
)
Also if you want the local contents only you can use the Flag.CACHE_MODE_LOCAL
flag so
that other remote nodes are not queried for data. However the loader will still be used unless the previously
mentioned Flag.SKIP_CACHE_LOAD
is also configured.
This class implements the CloseableIteratorCollection
interface which creates a
CloseableIterator
instead of a regular one. This means this iterator must be
explicitly closed either through try with resource or calling the close method directly. Technically this iterator
will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.
The iterator retrieved using CloseableIteratorCollection.iterator()
supports the remove method, however the
iterator retrieved from CacheStream.iterator()
will not support remove.
UnsupportedOperationException
if invoked.
Set.add(Object)
Set.addAll(java.util.Collection)
public AdvancedCache<K,V> with(ClassLoader classLoader)
with
in interface AdvancedCache<K,V>
public CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
AsyncCache
BasicCache.replace(Object, Object, Object, long, TimeUnit, long, TimeUnit)
. This method
does not block on remote calls, even if your cache mode is synchronous.replaceAsync
in interface AsyncCache<K,V>
key
- key to removeoldValue
- value to overwritenewValue
- value to storelifespan
- lifespan of entrylifespanUnit
- time unit for lifespanmaxIdle
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit
- time unit for max idle timepublic CacheSet<Map.Entry<K,V>> entrySet()
Cache
Set.toArray()
, Set.toArray(Object[])
,
Set.size()
, Set.retainAll(Collection)
and Set.iterator()
methods as they will traverse the entire contents of the cluster including a configured
CacheLoader
and remote entries. The former 2 methods especially have a
very high likely hood of causing a OutOfMemoryError
due to storing all the keys in the entire
cluster in the array.
Use involving execution of this method on a production system is not recommended as they can be quite expensive
operations
* Flag.SKIP_CACHE_LOAD
flag should be used to
avoid hitting the cache store as this will cause all entries there to be read in (albeit in a batched form to
prevent OutOfMemoryError
)
Also if you want the local contents only you can use the Flag.CACHE_MODE_LOCAL
flag so
that other remote nodes are not queried for data. However the loader will still be used unless the previously
mentioned Flag.SKIP_CACHE_LOAD
is also configured.
Map.Entry.setValue(Object)
and it will update
the cache as well. Also this backing set does allow addition of a new Map.Entry(s) via the
Set.add(Object)
or Set.addAll(java.util.Collection)
methods.
CloseableIteratorSet
interface which creates a
CloseableIterator
instead of a regular one. This means this iterator must be
explicitly closed either through try with resource or calling the close method directly. Technically this iterator
will also close itself if you iterate fully over it, but it is safest to always make sure you close it explicitly.public CompletableFuture<V> getAsync(K key)
AsyncCache
Map.get(Object)
that allows user code to
retrieve the value associated with a key at a later stage, hence allowing
multiple parallel get requests to be sent. Normally, when this method
detects that the value is likely to be retrieved from from a remote
entity, it will span a different thread in order to allow the
asynchronous get call to return immediately. If the call will definitely
resolve locally, for example when the cache is configured with LOCAL mode
and no stores are configured, the get asynchronous call will act
sequentially and will have no different to Map.get(Object)
.getAsync
in interface AsyncCache<K,V>
key
- key to retrieveMap.get(Object)
public V put(K key, V value, Metadata metadata)
AdvancedCache
#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.put
in interface AdvancedCache<K,V>
key
- key to usevalue
- value to storemetadata
- information to store alongside the valuepublic void putAll(Map<? extends K,? extends V> m, Metadata metadata)
AdvancedCache
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.putAll
in interface AdvancedCache<K,V>
m
- the values to storemetadata
- information to store alongside the value(s)public CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> map, Metadata metadata)
putAllAsync
in interface AdvancedCache<K,V>
public V replace(K key, V value, Metadata metadata)
AdvancedCache
#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.replace
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedvalue
- value to be associated with the specified keymetadata
- information to store alongside the new valuepublic CompletableFuture<V> replaceAsync(K key, V value, Metadata metadata)
AdvancedCache
#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.replaceAsync
in interface AdvancedCache<K,V>
key
- key with which the specified value is associatedvalue
- value to be associated with the specified keymetadata
- information to store alongside the new valuepublic boolean replace(K key, V oldValue, V newValue, Metadata metadata)
AdvancedCache
#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.replace
in interface AdvancedCache<K,V>
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 valuepublic CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, Metadata metadata)
replaceAsync
in interface AdvancedCache<K,V>
public void clear()
Cache
public V putIfAbsent(K key, V value, Metadata metadata)
AdvancedCache
#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.putIfAbsent
in interface AdvancedCache<K,V>
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 valuepublic CompletableFuture<V> putIfAbsentAsync(K key, V value, Metadata metadata)
AdvancedCache
#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.putIfAbsentAsync
in interface AdvancedCache<K,V>
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 valuepublic CompletableFuture<V> putAsync(K key, V value, Metadata metadata)
AdvancedCache
AdvancedCache.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 AdvancedCache.put(Object, Object, Metadata)
if used in LOCAL mode.
putAsync
in interface AdvancedCache<K,V>
key
- key to usevalue
- value to storemetadata
- information to store alongside the new valuepublic CacheEntry<K,V> getCacheEntry(Object key)
AdvancedCache
getCacheEntry
in interface AdvancedCache<K,V>
key
- the key whose associated cache entry is to be returnednull
if this map contains no mapping for
the keypublic CompletableFuture<CacheEntry<K,V>> getCacheEntryAsync(Object key)
AdvancedCache
getCacheEntryAsync
in interface AdvancedCache<K,V>
key
- the key whose associated cache entry is to be returnednull
if this map contains no mapping for the keypublic Map<K,CacheEntry<K,V>> getAllCacheEntries(Set<?> keys)
AdvancedCache
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.
getAllCacheEntries
in interface AdvancedCache<K,V>
keys
- The keys whose associated values are to be returned.public Map<K,V> getAndPutAll(Map<? extends K,? extends V> map)
AdvancedCache
Map.putAll(Map)
, returning previous values of the modified entries.getAndPutAll
in interface AdvancedCache<K,V>
map
- mappings to be stored in this mappublic Map<K,V> getGroup(String groupName)
AdvancedCache
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 AdvancedCache.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.getGroup
in interface AdvancedCache<K,V>
groupName
- the group name.Map
with the key/value pairs.public void removeGroup(String groupName)
AdvancedCache
removeGroup
in interface AdvancedCache<K,V>
groupName
- the group name.public boolean equals(Object o)
public int hashCode()
Copyright © 2021 JBoss by Red Hat. All rights reserved.