public class DecoratedCache<K,V> extends AbstractDelegatingAdvancedCache<K,V>
Flag
s. This
set of Flag
s will be applied to all cache invocations made via this decorator.
In addition to cleaner and more readable code, this approach offers a performance benefit to using
AdvancedCache.withFlags(Flag...)
API, thanks to
internal optimizations that can be made when the Flag
set is unchanging.
Note that DecoratedCache
must be the closest Delegate to the actual Cache implementation. All others
must delegate to this DecoratedCache.AdvancedCache.withFlags(Flag...)
cache
Constructor and Description |
---|
DecoratedCache(CacheImpl<K,V> delegate,
long flagsBitSet) |
DecoratedCache(CacheImpl<K,V> delegate,
Object lockOwner,
long newFlags) |
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,
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) . |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction) |
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) . |
V |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction) |
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) . |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
CacheSet<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this cache and cache loader across the entire cluster.
|
void |
evict(K key)
Evicts an entry from the memory of the cache.
|
V |
get(Object key) |
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. |
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. |
CacheEntry<K,V> |
getCacheEntry(Object key)
Retrieves a CacheEntry corresponding to a specific key.
|
CompletableFuture<CacheEntry<K,V>> |
getCacheEntryAsync(Object key)
Retrieves a CacheEntry corresponding to a specific key.
|
ClassLoader |
getClassLoader()
Returns the cache loader associated associated with this cache.
|
long |
getFlagsBitSet() |
Map<K,V> |
getGroup(String groupName)
It fetches all the keys which belong to the group.
|
Object |
getLockOwner() |
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,
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) . |
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> 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. |
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> data,
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. |
protected InvocationContext |
readContext(int size) |
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.
|
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 value,
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) |
AdvancedCache |
rewrap(AdvancedCache newDelegate)
No generics because some methods return
AdvancedCache<?, ?> ,
and returning the proper type would require erasure anyway. |
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 |
stop()
Stops a cache.
|
CacheCollection<V> |
values()
Returns a collection view of the values contained in this cache across the entire cluster.
|
AdvancedCache<K,V> |
with(ClassLoader classLoader) |
AdvancedCache<K,V> |
withEncoding(Class<? extends Encoder> encoderClass)
Performs any cache operations using the specified
Encoder . |
AdvancedCache<K,V> |
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<K,V> |
withFlags(Flag flag)
An alternative to
AdvancedCache.withFlags(Flag...) optimized for a single flag. |
AdvancedCache<K,V> |
withWrapping(Class<? extends Wrapper> wrapperClass)
Deprecated.
|
AdvancedCache<K,V> |
withWrapping(Class<? extends Wrapper> keyWrapperClass,
Class<? extends Wrapper> valueWrapperClass)
Deprecated.
|
protected InvocationContext |
writeContext(int size) |
computeAsync, computeAsync, computeAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresentAsync, computeIfPresentAsync, computeIfPresentAsync, getAdvancedCache, getAndPutAll, getAsyncInterceptorChain, getAuthorizationManager, getAvailability, getBatchContainer, getCacheAvailability, getComponentRegistry, getDataContainer, getDistributionManager, getEvictionManager, getExpirationManager, getKeyDataConversion, getLockManager, getRpcManager, getStats, getTransactionManager, getValueDataConversion, getXAResource, isRebalancingEnabled, mergeAsync, mergeAsync, mergeAsync, putForExternalRead, putForExternalRead, setAvailability, setCacheAvailability, setRebalancingEnabled, transform, withKeyEncoding, withMediaType, withStorageMediaType, withSubject
addFilteredListener, addListener, addListener, addStorageFormatFilteredListener, compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, endBatch, forEach, getCacheConfiguration, getCacheManager, getCacheName, getCacheStatus, getConfigurationAsProperties, getDelegate, getListeners, getName, getOrDefault, getStatus, getVersion, merge, merge, removeListener, removeListenerAsync, replaceAll, set, shutdown, start, startBatch, toString, unwrapCache
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
compute, computeAsync, computeIfAbsent, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, merge, mergeAsync
compute, compute, compute, computeAsync, computeAsync, computeAsync, computeIfAbsent, computeIfAbsent, computeIfAbsent, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, getCacheConfiguration, getCacheManager, getStatus, merge, merge, merge, mergeAsync, mergeAsync, mergeAsync, shutdown
compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getName, getVersion, merge, merge
containsKeyAsync
forEach, getOrDefault, replaceAll
endBatch, startBatch
addFilteredListener, addListener, addStorageFormatFilteredListener
addListener, getListeners, removeListener, removeListenerAsync
public AdvancedCache rewrap(AdvancedCache newDelegate)
AbstractDelegatingAdvancedCache
AdvancedCache<?, ?>
,
and returning the proper type would require erasure anyway.rewrap
in class AbstractDelegatingAdvancedCache<K,V>
public AdvancedCache<K,V> with(ClassLoader classLoader)
with
in interface AdvancedCache<K,V>
with
in class AbstractDelegatingAdvancedCache<K,V>
public 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>
withFlags
in class AbstractDelegatingAdvancedCache<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>
withFlags
in class AbstractDelegatingAdvancedCache<K,V>
public AdvancedCache<K,V> withFlags(Flag flag)
AdvancedCache
AdvancedCache.withFlags(Flag...)
optimized for a single flag.public AdvancedCache<K,V> noFlags()
AdvancedCache
AdvancedCache.withFlags(Flag...)
or AdvancedCache.withFlags(Collection)
methods.noFlags
in interface AdvancedCache<K,V>
noFlags
in class AbstractDelegatingAdvancedCache<K,V>
this
.public AdvancedCache<K,V> withEncoding(Class<? extends Encoder> encoderClass)
AdvancedCache
Encoder
.withEncoding
in interface AdvancedCache<K,V>
withEncoding
in class AbstractDelegatingAdvancedCache<K,V>
encoderClass
- Encoder
used for both keys and values.AdvancedCache
where all operations will use the supplied encoder.public AdvancedCache<K,V> withEncoding(Class<? extends Encoder> keyEncoderClass, Class<? extends Encoder> valueEncoderClass)
AdvancedCache
Encoder
.withEncoding
in interface AdvancedCache<K,V>
withEncoding
in class AbstractDelegatingAdvancedCache<K,V>
keyEncoderClass
- Encoder
for the keys.valueEncoderClass
- Encoder
for the values.AdvancedCache
where all operations will use the supplied encoders.@Deprecated public AdvancedCache<K,V> withWrapping(Class<? extends Wrapper> wrapperClass)
AdvancedCache
Wrapper
.withWrapping
in interface AdvancedCache<K,V>
withWrapping
in class AbstractDelegatingAdvancedCache<K,V>
wrapperClass
- Wrapper
for the keys and values.AdvancedCache
where all operations will use the supplied wrapper.@Deprecated public AdvancedCache<K,V> withWrapping(Class<? extends Wrapper> keyWrapperClass, Class<? extends Wrapper> valueWrapperClass)
AdvancedCache
Wrapper
.withWrapping
in interface AdvancedCache<K,V>
withWrapping
in class AbstractDelegatingAdvancedCache<K,V>
keyWrapperClass
- Wrapper
for the keys.valueWrapperClass
- Wrapper
for the values.AdvancedCache
where all operations will use the supplied wrappers.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>
lockAs
in class AbstractDelegatingAdvancedCache<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 Object getLockOwner()
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>
lockedStream
in class AbstractDelegatingAdvancedCache<K,V>
public ClassLoader getClassLoader()
AdvancedCache
DecoratedCache
wrapper.getClassLoader
in interface AdvancedCache<K,V>
getClassLoader
in class AbstractDelegatingAdvancedCache<K,V>
public void stop()
Cache
Cache.shutdown()
method.public boolean lock(K... keys)
AdvancedCache
Keys can be locked eagerly in the context of a transaction only.
lock
in interface AdvancedCache<K,V>
lock
in class AbstractDelegatingAdvancedCache<K,V>
keys
- the keys to lockFlag.FAIL_SILENTLY
.public 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>
lock
in class AbstractDelegatingAdvancedCache<K,V>
keys
- collection of keys to lockFlag.FAIL_SILENTLY
.public void putForExternalRead(K key, V value)
Cache
ConcurrentMap.putIfAbsent(Object, Object)
)
putForExternalRead
in interface Cache<K,V>
putForExternalRead
in class AbstractDelegatingCache<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>
putForExternalRead
in class AbstractDelegatingAdvancedCache<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 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>
putForExternalRead
in class AbstractDelegatingCache<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>
putForExternalRead
in class AbstractDelegatingCache<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 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 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>
put
in class AbstractDelegatingCache<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 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>
putIfAbsent
in class AbstractDelegatingCache<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 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>
putAll
in class AbstractDelegatingCache<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 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>
replace
in class AbstractDelegatingCache<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 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>
replace
in class AbstractDelegatingCache<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 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>
put
in class AbstractDelegatingCache<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 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>
putIfAbsent
in class AbstractDelegatingCache<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 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>
putAll
in class AbstractDelegatingCache<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 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>
replace
in class AbstractDelegatingCache<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 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>
replace
in class AbstractDelegatingCache<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 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>
putAsync
in class AbstractDelegatingCache<K,V>
key
- key to usevalue
- value to storepublic 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>
putAsync
in class AbstractDelegatingCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic 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>
putAsync
in class AbstractDelegatingCache<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 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>
putAllAsync
in class AbstractDelegatingCache<K,V>
data
- to storepublic 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>
putAllAsync
in class AbstractDelegatingCache<K,V>
data
- to storelifespan
- lifespan of entryunit
- time unit for 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>
putAllAsync
in class AbstractDelegatingCache<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 CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data, Metadata metadata)
putAllAsync
in interface AdvancedCache<K,V>
putAllAsync
in class AbstractDelegatingAdvancedCache<K,V>
public 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>
clearAsync
in class AbstractDelegatingCache<K,V>
public 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>
putIfAbsentAsync
in class AbstractDelegatingCache<K,V>
key
- key to usevalue
- value to storepublic 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>
putIfAbsentAsync
in class AbstractDelegatingCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic 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>
putIfAbsentAsync
in class AbstractDelegatingCache<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 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>
putIfAbsentAsync
in class AbstractDelegatingAdvancedCache<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> 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>
removeAsync
in class AbstractDelegatingCache<K,V>
key
- key to removepublic 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>
removeAsync
in class AbstractDelegatingCache<K,V>
key
- key to removevalue
- value to match onpublic 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>
removeLifespanExpired
in class AbstractDelegatingAdvancedCache<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>
removeMaxIdleExpired
in class AbstractDelegatingAdvancedCache<K,V>
key
- the key that expired via max idle for the given entrypublic 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>
replaceAsync
in class AbstractDelegatingCache<K,V>
key
- key to removevalue
- value to storepublic 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>
replaceAsync
in class AbstractDelegatingCache<K,V>
key
- key to removevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic 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>
replaceAsync
in class AbstractDelegatingCache<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 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>
replaceAsync
in class AbstractDelegatingAdvancedCache<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<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>
replaceAsync
in class AbstractDelegatingCache<K,V>
key
- key to removeoldValue
- value to overwritenewValue
- value to storepublic 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>
replaceAsync
in class AbstractDelegatingCache<K,V>
key
- key to removeoldValue
- value to overwritenewValue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic 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>
replaceAsync
in class AbstractDelegatingCache<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 CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, Metadata metadata)
replaceAsync
in interface AdvancedCache<K,V>
replaceAsync
in class AbstractDelegatingAdvancedCache<K,V>
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>
getAsync
in class AbstractDelegatingCache<K,V>
key
- key to retrieveMap.get(Object)
public CompletableFuture<Map<K,V>> getAllAsync(Set<?> keys)
AsyncCache
getAllAsync
in interface AsyncCache<K,V>
getAllAsync
in class AbstractDelegatingAdvancedCache<K,V>
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>
sizeAsync
in class AbstractDelegatingCache<K,V>
public boolean isEmpty()
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in class AbstractDelegatingCache<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
containsValue
in class AbstractDelegatingCache<K,V>
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>
getAll
in class AbstractDelegatingAdvancedCache<K,V>
keys
- The keys whose associated values are to be returned.public 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>
getAllCacheEntries
in class AbstractDelegatingAdvancedCache<K,V>
keys
- The keys whose associated values are to be returned.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 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 void putAll(Map<? extends K,? extends V> map, 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>
putAll
in class AbstractDelegatingAdvancedCache<K,V>
map
- the values to storemetadata
- information to store alongside the value(s)public void clear()
Cache
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 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>
getGroup
in class AbstractDelegatingAdvancedCache<K,V>
groupName
- the group name.Map
with the key/value pairs.public void removeGroup(String groupName)
AdvancedCache
removeGroup
in interface AdvancedCache<K,V>
removeGroup
in class AbstractDelegatingAdvancedCache<K,V>
groupName
- the group name.public 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 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 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>
cacheEntrySet
in class AbstractDelegatingAdvancedCache<K,V>
Cache.entrySet()
public V putIfAbsent(K key, V value)
putIfAbsent
in interface ConcurrentMap<K,V>
putIfAbsent
in interface Map<K,V>
putIfAbsent
in class AbstractDelegatingCache<K,V>
public 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 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>
computeIfPresent
in class AbstractDelegatingCache<K,V>
public 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>
computeIfAbsent
in class AbstractDelegatingCache<K,V>
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 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>
computeAsync
in class AbstractDelegatingAdvancedCache<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>
computeIfPresentAsync
in class AbstractDelegatingAdvancedCache<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>
computeIfAbsentAsync
in class AbstractDelegatingAdvancedCache<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>
mergeAsync
in class AbstractDelegatingAdvancedCache<K,V>
public long getFlagsBitSet()
public CompletionStage<Void> addListenerAsync(Object listener)
Listenable
Listenable.addListener(Object)
addListenerAsync
in interface Listenable
addListenerAsync
in class AbstractDelegatingCache<K,V>
listener
- listener to add, must not be nullpublic <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>
addListenerAsync
in class AbstractDelegatingCache<K,V>
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>
addFilteredListenerAsync
in class AbstractDelegatingCache<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>
addStorageFormatFilteredListenerAsync
in class AbstractDelegatingCache<K,V>
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>
put
in class AbstractDelegatingAdvancedCache<K,V>
key
- key to usevalue
- value to storemetadata
- information to store alongside the 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>
putAsync
in class AbstractDelegatingAdvancedCache<K,V>
key
- key to usevalue
- value to storemetadata
- information to store alongside the new valuepublic 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>
putIfAbsent
in class AbstractDelegatingAdvancedCache<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 boolean replace(K key, V oldValue, V value, 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>
replace
in class AbstractDelegatingAdvancedCache<K,V>
key
- key with which the specified value is associatedoldValue
- value expected to be associated with the specified keyvalue
- value to be associated with the specified keymetadata
- information to store alongside the new valuepublic 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>
replace
in class AbstractDelegatingAdvancedCache<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 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>
compute
in class AbstractDelegatingAdvancedCache<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, 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>
computeIfPresent
in class AbstractDelegatingAdvancedCache<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 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>
computeIfAbsent
in class AbstractDelegatingAdvancedCache<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 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>
merge
in class AbstractDelegatingAdvancedCache<K,V>
public CacheEntry<K,V> getCacheEntry(Object key)
AdvancedCache
getCacheEntry
in interface AdvancedCache<K,V>
getCacheEntry
in class AbstractDelegatingAdvancedCache<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>
getCacheEntryAsync
in class AbstractDelegatingAdvancedCache<K,V>
key
- the key whose associated cache entry is to be returnednull
if this map contains no mapping for the keyprotected InvocationContext readContext(int size)
protected InvocationContext writeContext(int size)
Copyright © 2021 JBoss by Red Hat. All rights reserved.