public class DecoratedCache<K,V> extends AbstractDelegatingAdvancedCache<K,V>
ClassLoader
and a set of Flag
s. This
ClassLoader
and 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.with(ClassLoader)
or AdvancedCache.withFlags(org.infinispan.context.Flag...)
APIs, thanks to
internal optimizations that can be made when the ClassLoader
and Flag
set is unchanging.AdvancedCache.with(ClassLoader)
,
AdvancedCache.withFlags(org.infinispan.context.Flag...)
AbstractDelegatingAdvancedCache.AdvancedCacheWrapper<K,V>
Modifier and Type | Field and Description |
---|---|
private CacheImpl<K,V> |
cacheImplementation |
private java.lang.ref.WeakReference<java.lang.ClassLoader> |
classLoader |
private java.util.EnumSet<org.infinispan.context.Flag> |
flags |
cache
Modifier | Constructor and Description |
---|---|
|
DecoratedCache(AdvancedCache<K,V> delegate,
java.lang.ClassLoader classLoader) |
|
DecoratedCache(AdvancedCache<K,V> delegate,
java.lang.ClassLoader classLoader,
org.infinispan.context.Flag... flags) |
|
DecoratedCache(AdvancedCache<K,V> delegate,
org.infinispan.context.Flag... flags) |
private |
DecoratedCache(CacheImpl<K,V> delegate,
java.lang.ClassLoader classLoader,
java.util.EnumSet<org.infinispan.context.Flag> newFlags) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(java.lang.Object listener)
Adds a listener to the component.
|
void |
addListener(java.lang.Object listener,
org.infinispan.notifications.KeyFilter filter)
Adds a listener to the component.
|
void |
clear() |
org.infinispan.util.concurrent.NotifyingFuture<java.lang.Void> |
clearAsync()
Asynchronous version of
#clear() . |
boolean |
containsKey(java.lang.Object key) |
java.util.Set< |
entrySet()
Returns a set view of the mappings contained in this cache and cache loader.
|
void |
evict(K key)
Evicts an entry from the memory of the cache.
|
V |
get(java.lang.Object key) |
org.infinispan.util.concurrent.NotifyingFuture<V> |
getAsync(K key)
Asynchronous version of
#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. |
org.infinispan.container.entries.CacheEntry |
getCacheEntry(K key) |
java.lang.ClassLoader |
getClassLoader()
Returns the cache loader associated associated with this cache.
|
java.util.EnumSet<org.infinispan.context.Flag> |
getFlags() |
boolean |
isEmpty() |
java.util.Set<K> |
keySet()
Returns a set view of the keys contained in this cache and cache loader.
|
boolean |
lock(java.util.Collection<? extends K> keys) |
boolean |
lock(K... keys) |
V |
put(K key,
V value) |
V |
put(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit unit) |
V |
put(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdleTime,
java.util.concurrent.TimeUnit maxIdleTimeUnit) |
V |
put(K key,
V value,
org.infinispan.metadata.Metadata metadata) |
void |
putAll(java.util.Map<? extends K,? extends V> m) |
void |
putAll(java.util.Map<? extends K,? extends V> map,
long lifespan,
java.util.concurrent.TimeUnit unit) |
void |
putAll(java.util.Map<? extends K,? extends V> map,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdleTime,
java.util.concurrent.TimeUnit maxIdleTimeUnit) |
org.infinispan.util.concurrent.NotifyingFuture<java.lang.Void> |
putAllAsync(java.util.Map<? extends K,? extends V> data)
Asynchronous version of
#putAll(Map) . |
org.infinispan.util.concurrent.NotifyingFuture<java.lang.Void> |
putAllAsync(java.util.Map<? extends K,? extends V> data,
long lifespan,
java.util.concurrent.TimeUnit unit)
Asynchronous version of
#putAll(Map, long, TimeUnit) . |
org.infinispan.util.concurrent.NotifyingFuture<java.lang.Void> |
putAllAsync(java.util.Map<? extends K,? extends V> data,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdle,
java.util.concurrent.TimeUnit maxIdleUnit)
Asynchronous version of
#putAll(Map, long, TimeUnit, long, TimeUnit) . |
org.infinispan.util.concurrent.NotifyingFuture<V> |
putAsync(K key,
V value)
Asynchronous version of
#put(Object, Object) . |
org.infinispan.util.concurrent.NotifyingFuture<V> |
putAsync(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit unit)
Asynchronous version of
#put(Object, Object, long, TimeUnit) . |
org.infinispan.util.concurrent.NotifyingFuture<V> |
putAsync(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdle,
java.util.concurrent.TimeUnit maxIdleUnit)
Asynchronous version of
#put(Object, Object, long, TimeUnit, long, TimeUnit) . |
org.infinispan.util.concurrent.NotifyingFuture<V> |
putAsync(K key,
V value,
org.infinispan.metadata.Metadata metadata) |
void |
putForExternalRead(K key,
V value)
Under special operating behavior, associates the value with the specified key.
|
V |
putIfAbsent(K key,
V value) |
V |
putIfAbsent(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit unit) |
V |
putIfAbsent(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdleTime,
java.util.concurrent.TimeUnit maxIdleTimeUnit) |
V |
putIfAbsent(K key,
V value,
org.infinispan.metadata.Metadata metadata) |
org.infinispan.util.concurrent.NotifyingFuture<V> |
putIfAbsentAsync(K key,
V value)
Asynchronous version of
#putIfAbsent(Object, Object) . |
org.infinispan.util.concurrent.NotifyingFuture<V> |
putIfAbsentAsync(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit unit)
Asynchronous version of
#putIfAbsent(Object, Object, long, TimeUnit) . |
org.infinispan.util.concurrent.NotifyingFuture<V> |
putIfAbsentAsync(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdle,
java.util.concurrent.TimeUnit maxIdleUnit)
Asynchronous version of
#putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit) . |
V |
remove(java.lang.Object key) |
boolean |
remove(java.lang.Object key,
java.lang.Object value) |
org.infinispan.util.concurrent.NotifyingFuture<V> |
removeAsync(java.lang.Object key)
Asynchronous version of
#remove(Object) . |
org.infinispan.util.concurrent.NotifyingFuture<java.lang.Boolean> |
removeAsync(java.lang.Object key,
java.lang.Object value)
Asynchronous version of
#remove(Object, Object) . |
V |
replace(K key,
V value) |
V |
replace(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit unit) |
V |
replace(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdleTime,
java.util.concurrent.TimeUnit maxIdleTimeUnit) |
V |
replace(K key,
V value,
org.infinispan.metadata.Metadata metadata) |
boolean |
replace(K key,
V oldValue,
V newValue) |
boolean |
replace(K key,
V oldValue,
V value,
long lifespan,
java.util.concurrent.TimeUnit unit) |
boolean |
replace(K key,
V oldValue,
V value,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdleTime,
java.util.concurrent.TimeUnit maxIdleTimeUnit) |
boolean |
replace(K key,
V oldValue,
V value,
org.infinispan.metadata.Metadata metadata) |
org.infinispan.util.concurrent.NotifyingFuture<V> |
replaceAsync(K key,
V value)
Asynchronous version of
#replace(Object, Object) . |
org.infinispan.util.concurrent.NotifyingFuture<V> |
replaceAsync(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit unit)
Asynchronous version of
#replace(Object, Object, long, TimeUnit) . |
org.infinispan.util.concurrent.NotifyingFuture<V> |
replaceAsync(K key,
V value,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdle,
java.util.concurrent.TimeUnit maxIdleUnit)
Asynchronous version of
#replace(Object, Object, long, TimeUnit, long, TimeUnit) . |
org.infinispan.util.concurrent.NotifyingFuture<java.lang.Boolean> |
replaceAsync(K key,
V oldValue,
V newValue)
Asynchronous version of
#replace(Object, Object, Object) . |
org.infinispan.util.concurrent.NotifyingFuture<java.lang.Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
long lifespan,
java.util.concurrent.TimeUnit unit)
Asynchronous version of
#replace(Object, Object, Object, long, TimeUnit) . |
org.infinispan.util.concurrent.NotifyingFuture<java.lang.Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
long lifespan,
java.util.concurrent.TimeUnit lifespanUnit,
long maxIdle,
java.util.concurrent.TimeUnit maxIdleUnit)
Asynchronous version of
#replace(Object, Object, Object, long, TimeUnit, long, TimeUnit) . |
int |
size()
Returns a count of all elements in this cache and cache loader.
|
void |
stop() |
java.util.Collection<V> |
values()
Returns a collection view of the values contained in this cache.
|
AdvancedCache<K,V> |
with(java.lang.ClassLoader classLoader)
Using this operation, users can call any
AdvancedCache operation
with a given ClassLoader . |
AdvancedCache<K,V> |
withFlags(org.infinispan.context.Flag... flags)
A method that adds flags to any API call.
|
addInterceptor, addInterceptorAfter, addInterceptorBefore, applyDelta, getAdvancedCache, getBatchContainer, getComponentRegistry, getDataContainer, getDistributionManager, getEvictionManager, getInterceptorChain, getInvocationContextContainer, getLockManager, getRpcManager, getStats, getTransactionManager, getXAResource, putForExternalRead, removeInterceptor, removeInterceptor
containsValue, endBatch, getCacheConfiguration, getCacheManager, getDelegate, getListeners, getName, getStatus, getVersion, removeListener, set, start, startBatch, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addInterceptorAfter, addInterceptorBefore, applyDelta, getCacheEntry, lock, lock, put, putAsync, putIfAbsent, removeInterceptor, replace, replace
getCacheConfiguration, getCacheManager, getStatus
private final java.util.EnumSet<org.infinispan.context.Flag> flags
private final java.lang.ref.WeakReference<java.lang.ClassLoader> classLoader
public DecoratedCache(AdvancedCache<K,V> delegate, java.lang.ClassLoader classLoader)
public DecoratedCache(AdvancedCache<K,V> delegate, org.infinispan.context.Flag... flags)
public DecoratedCache(AdvancedCache<K,V> delegate, java.lang.ClassLoader classLoader, org.infinispan.context.Flag... flags)
public AdvancedCache<K,V> with(java.lang.ClassLoader classLoader)
AdvancedCache
AdvancedCache
operation
with a given ClassLoader
. This means that any ClassLoader
happening
as a result of the cache operation will be done using the ClassLoader
given. For example:
When users store POJO instances in caches configured with StoreAsBinaryConfiguration
,
these instances are transformed into byte arrays. When these entries are
read from the cache, a lazy unmarshalling process happens where these byte
arrays are transformed back into POJO instances. Using AdvancedCache.with(ClassLoader)
when reading that enables users to provide the class loader that should
be used when trying to locate the classes that are constructed as a result
of the unmarshalling process.
cache.with(classLoader).get(key);Note that for the flag to take effect, the cache operation must be invoked on the instance returned by this method. As an alternative to setting this on every invocation, users could also consider using the
DecoratedCache
wrapper, as this allows for more readable
code. E.g.:
Cache classLoaderSpecificCache = new DecoratedCache(cache, classLoader); classLoaderSpecificCache.get(key1); classLoaderSpecificCache.get(key2); classLoaderSpecificCache.get(key3);
with
in interface AdvancedCache<K,V>
with
in class AbstractDelegatingAdvancedCache<K,V>
AdvancedCache
instance upon which operations can be called
with a particular ClassLoader
.public AdvancedCache<K,V> withFlags(org.infinispan.context.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 could also consider using the
DecoratedCache
wrapper, as this allows for more readable
code. E.g.:
Cache forceWriteLockCache = new DecoratedCache(cache, Flag.FORCE_WRITE_LOCK); forceWriteLockCache.get(key1); forceWriteLockCache.get(key2); forceWriteLockCache.get(key3);
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 java.lang.ClassLoader getClassLoader()
AdvancedCache
DecoratedCache
wrapper.getClassLoader
in interface AdvancedCache<K,V>
getClassLoader
in class AbstractDelegatingAdvancedCache<K,V>
public void stop()
stop
in class AbstractDelegatingCache<K,V>
public boolean lock(K... keys)
lock
in class AbstractDelegatingAdvancedCache<K,V>
public boolean lock(java.util.Collection<? extends K> keys)
lock
in class AbstractDelegatingAdvancedCache<K,V>
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 evict(K key)
Cache
#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, java.util.concurrent.TimeUnit unit)
put
in class AbstractDelegatingCache<K,V>
public V putIfAbsent(K key, V value, long lifespan, java.util.concurrent.TimeUnit unit)
putIfAbsent
in class AbstractDelegatingCache<K,V>
public void putAll(java.util.Map<? extends K,? extends V> map, long lifespan, java.util.concurrent.TimeUnit unit)
putAll
in class AbstractDelegatingCache<K,V>
public V replace(K key, V value, long lifespan, java.util.concurrent.TimeUnit unit)
replace
in class AbstractDelegatingCache<K,V>
public boolean replace(K key, V oldValue, V value, long lifespan, java.util.concurrent.TimeUnit unit)
replace
in class AbstractDelegatingCache<K,V>
public V put(K key, V value, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
put
in class AbstractDelegatingCache<K,V>
public V putIfAbsent(K key, V value, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
putIfAbsent
in class AbstractDelegatingCache<K,V>
public void putAll(java.util.Map<? extends K,? extends V> map, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
putAll
in class AbstractDelegatingCache<K,V>
public V replace(K key, V value, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
replace
in class AbstractDelegatingCache<K,V>
public boolean replace(K key, V oldValue, V value, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdleTime, java.util.concurrent.TimeUnit maxIdleTimeUnit)
replace
in class AbstractDelegatingCache<K,V>
public org.infinispan.util.concurrent.NotifyingFuture<V> putAsync(K key, V value)
org.infinispan.api.BasicCache
#put(Object, Object)
. This method does not block on remote calls, even if your
cache mode is synchronous. Has no benefit over #put(Object, Object)
if used in LOCAL mode.
public org.infinispan.util.concurrent.NotifyingFuture<V> putAsync(K key, V value, long lifespan, java.util.concurrent.TimeUnit unit)
org.infinispan.api.BasicCache
#put(Object, Object, long, TimeUnit)
. This method does not block on remote
calls, even if your cache mode is synchronous. Has no benefit over #put(Object, Object, long, TimeUnit)
if used in LOCAL mode.public org.infinispan.util.concurrent.NotifyingFuture<V> putAsync(K key, V value, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdle, java.util.concurrent.TimeUnit maxIdleUnit)
org.infinispan.api.BasicCache
#put(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not block
on remote calls, even if your cache mode is synchronous. Has no benefit over #put(Object, Object, long,
TimeUnit, long, TimeUnit)
if used in LOCAL mode.putAsync
in interface org.infinispan.api.BasicCache<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 org.infinispan.util.concurrent.NotifyingFuture<java.lang.Void> putAllAsync(java.util.Map<? extends K,? extends V> data)
org.infinispan.api.BasicCache
#putAll(Map)
. This method does not block on remote calls, even if your cache mode
is synchronous. Has no benefit over #putAll(Map)
if used in LOCAL mode.putAllAsync
in interface org.infinispan.api.BasicCache<K,V>
putAllAsync
in class AbstractDelegatingCache<K,V>
data
- to storepublic org.infinispan.util.concurrent.NotifyingFuture<java.lang.Void> putAllAsync(java.util.Map<? extends K,? extends V> data, long lifespan, java.util.concurrent.TimeUnit unit)
org.infinispan.api.BasicCache
#putAll(Map, long, TimeUnit)
. This method does not block on remote calls, even if
your cache mode is synchronous. Has no benefit over #putAll(Map, long, TimeUnit)
if used in LOCAL mode.putAllAsync
in interface org.infinispan.api.BasicCache<K,V>
putAllAsync
in class AbstractDelegatingCache<K,V>
data
- to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic org.infinispan.util.concurrent.NotifyingFuture<java.lang.Void> putAllAsync(java.util.Map<? extends K,? extends V> data, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdle, java.util.concurrent.TimeUnit maxIdleUnit)
org.infinispan.api.BasicCache
#putAll(Map, long, TimeUnit, long, TimeUnit)
. This method does not block on
remote calls, even if your cache mode is synchronous. Has no benefit over #putAll(Map, long, TimeUnit,
long, TimeUnit)
if used in LOCAL mode.putAllAsync
in interface org.infinispan.api.BasicCache<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 org.infinispan.util.concurrent.NotifyingFuture<java.lang.Void> clearAsync()
org.infinispan.api.BasicCache
#clear()
. This method does not block on remote calls, even if your cache mode is
synchronous. Has no benefit over #clear()
if used in LOCAL mode.clearAsync
in interface org.infinispan.api.BasicCache<K,V>
clearAsync
in class AbstractDelegatingCache<K,V>
public org.infinispan.util.concurrent.NotifyingFuture<V> putIfAbsentAsync(K key, V value)
org.infinispan.api.BasicCache
#putIfAbsent(Object, Object)
. This method does not block on remote calls, even if
your cache mode is synchronous. Has no benefit over #putIfAbsent(Object, Object)
if used in LOCAL mode.
putIfAbsentAsync
in interface org.infinispan.api.BasicCache<K,V>
putIfAbsentAsync
in class AbstractDelegatingCache<K,V>
key
- key to usevalue
- value to storepublic org.infinispan.util.concurrent.NotifyingFuture<V> putIfAbsentAsync(K key, V value, long lifespan, java.util.concurrent.TimeUnit unit)
org.infinispan.api.BasicCache
#putIfAbsent(Object, Object, long, TimeUnit)
. This method does not block on
remote calls, even if your cache mode is synchronous. Has no benefit over #putIfAbsent(Object, Object,
long, TimeUnit)
if used in LOCAL mode.putIfAbsentAsync
in interface org.infinispan.api.BasicCache<K,V>
putIfAbsentAsync
in class AbstractDelegatingCache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic org.infinispan.util.concurrent.NotifyingFuture<V> putIfAbsentAsync(K key, V value, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdle, java.util.concurrent.TimeUnit maxIdleUnit)
org.infinispan.api.BasicCache
#putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does
not block on remote calls, even if your cache mode is synchronous. Has no benefit over #putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
if used in LOCAL mode.putIfAbsentAsync
in interface org.infinispan.api.BasicCache<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 org.infinispan.util.concurrent.NotifyingFuture<V> removeAsync(java.lang.Object key)
org.infinispan.api.BasicCache
#remove(Object)
. This method does not block on remote calls, even if your cache
mode is synchronous. Has no benefit over #remove(Object)
if used in LOCAL mode.removeAsync
in interface org.infinispan.api.BasicCache<K,V>
removeAsync
in class AbstractDelegatingCache<K,V>
key
- key to removepublic org.infinispan.util.concurrent.NotifyingFuture<java.lang.Boolean> removeAsync(java.lang.Object key, java.lang.Object value)
org.infinispan.api.BasicCache
#remove(Object, Object)
. This method does not block on remote calls, even if your
cache mode is synchronous. Has no benefit over #remove(Object, Object)
if used in LOCAL mode.removeAsync
in interface org.infinispan.api.BasicCache<K,V>
removeAsync
in class AbstractDelegatingCache<K,V>
key
- key to removevalue
- value to match onpublic org.infinispan.util.concurrent.NotifyingFuture<V> replaceAsync(K key, V value)
org.infinispan.api.BasicCache
#replace(Object, Object)
. This method does not block on remote calls, even if
your cache mode is synchronous. Has no benefit over #replace(Object, Object)
if used in LOCAL mode.replaceAsync
in interface org.infinispan.api.BasicCache<K,V>
replaceAsync
in class AbstractDelegatingCache<K,V>
key
- key to removevalue
- value to storepublic org.infinispan.util.concurrent.NotifyingFuture<V> replaceAsync(K key, V value, long lifespan, java.util.concurrent.TimeUnit unit)
org.infinispan.api.BasicCache
#replace(Object, Object, long, TimeUnit)
. This method does not block on remote
calls, even if your cache mode is synchronous. Has no benefit over #replace(Object, Object, long,
TimeUnit)
if used in LOCAL mode.replaceAsync
in interface org.infinispan.api.BasicCache<K,V>
replaceAsync
in class AbstractDelegatingCache<K,V>
key
- key to removevalue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespanpublic org.infinispan.util.concurrent.NotifyingFuture<V> replaceAsync(K key, V value, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdle, java.util.concurrent.TimeUnit maxIdleUnit)
org.infinispan.api.BasicCache
#replace(Object, Object, long, TimeUnit, long, TimeUnit)
. This method does not
block on remote calls, even if your cache mode is synchronous. Has no benefit over #replace(Object,
Object, long, TimeUnit, long, TimeUnit)
if used in LOCAL mode.replaceAsync
in interface org.infinispan.api.BasicCache<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 org.infinispan.util.concurrent.NotifyingFuture<java.lang.Boolean> replaceAsync(K key, V oldValue, V newValue)
org.infinispan.api.BasicCache
#replace(Object, Object, Object)
. This method does not block on remote calls,
even if your cache mode is synchronous. Has no benefit over #replace(Object, Object, Object)
if used in
LOCAL mode.replaceAsync
in interface org.infinispan.api.BasicCache<K,V>
replaceAsync
in class AbstractDelegatingCache<K,V>
key
- key to removeoldValue
- value to overwritenewValue
- value to storepublic org.infinispan.util.concurrent.NotifyingFuture<java.lang.Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, java.util.concurrent.TimeUnit unit)
org.infinispan.api.BasicCache
#replace(Object, Object, Object, long, TimeUnit)
. This method does not block on
remote calls, even if your cache mode is synchronous. Has no benefit over #replace(Object, Object, Object,
long, TimeUnit)
if used in LOCAL mode.replaceAsync
in interface org.infinispan.api.BasicCache<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 org.infinispan.util.concurrent.NotifyingFuture<java.lang.Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, java.util.concurrent.TimeUnit lifespanUnit, long maxIdle, java.util.concurrent.TimeUnit maxIdleUnit)
org.infinispan.api.BasicCache
#replace(Object, Object, Object, long, TimeUnit, long, TimeUnit)
. This method
does not block on remote calls, even if your cache mode is synchronous. Has no benefit over #replace(Object, Object, Object, long, TimeUnit, long, TimeUnit)
if used in LOCAL mode.replaceAsync
in interface org.infinispan.api.BasicCache<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 org.infinispan.util.concurrent.NotifyingFuture<V> getAsync(K key)
org.infinispan.api.BasicCache
#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 #get(Object)
.getAsync
in interface org.infinispan.api.BasicCache<K,V>
getAsync
in class AbstractDelegatingCache<K,V>
key
- key to retrieve#get(Object)
public int size()
Cache
org.infinispan.context.Flag.SKIP_CACHE_LOAD
flag should be used to
avoid hitting the cache store as all local keys will be loaded into memory at once.
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 boolean isEmpty()
isEmpty
in class AbstractDelegatingCache<K,V>
public boolean containsKey(java.lang.Object key)
containsKey
in class AbstractDelegatingCache<K,V>
public V get(java.lang.Object key)
get
in class AbstractDelegatingCache<K,V>
public V remove(java.lang.Object key)
remove
in class AbstractDelegatingCache<K,V>
public void putAll(java.util.Map<? extends K,? extends V> m)
putAll
in class AbstractDelegatingCache<K,V>
public void clear()
clear
in class AbstractDelegatingCache<K,V>
public java.util.Set<K> keySet()
Cache
org.infinispan.context.Flag.SKIP_CACHE_LOAD
flag should be used to
avoid hitting the cache store as all local keys will be in memory at once.
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 java.util.Collection<V> values()
Cache
org.infinispan.context.Flag.SKIP_CACHE_LOAD
flag should be used to
avoid hitting the cache store as all local values will be in memory at once.
This method should only be used for testing or debugging purposes such as to verify that the cache contains all the
values entered. Any other use involving execution of this method on a production system is not recommended.
public java.util.Set<> entrySet()
Cache
Map.Entry
. When this method is called on a cache configured with distribution mode, the set
returned only contains the mappings locally available in the cache instance. To avoid memory issues, there will
be not attempt to bring mappings from other nodes.
If there are memory concerns then the org.infinispan.context.Flag.SKIP_CACHE_LOAD
flag should be used to
avoid hitting the cache store as all local entries will be in memory at once.
This method should only be used for debugging purposes such as to verify that the cache contains all the mappings
entered. Any other use involving execution of this method on a production system is not recommended.
public V putIfAbsent(K key, V value)
putIfAbsent
in class AbstractDelegatingCache<K,V>
public boolean remove(java.lang.Object key, java.lang.Object value)
remove
in class AbstractDelegatingCache<K,V>
public boolean replace(K key, V oldValue, V newValue)
replace
in class AbstractDelegatingCache<K,V>
public java.util.EnumSet<org.infinispan.context.Flag> getFlags()
public void addListener(java.lang.Object listener)
org.infinispan.notifications.Listenable
Listener
and
further to that, contain methods annotated appropriately, otherwise the listener will not be registered.
See the Listener
annotation for more information.
addListener
in interface org.infinispan.notifications.Listenable
addListener
in class AbstractDelegatingCache<K,V>
listener
- must not be null.public void addListener(java.lang.Object listener, org.infinispan.notifications.KeyFilter filter)
org.infinispan.notifications.FilteringListenable
Listener
and
further to that, contain methods annotated appropriately, otherwise the listener will not be registered.
See the Listener
annotation for more information.
addListener
in interface org.infinispan.notifications.FilteringListenable
addListener
in class AbstractDelegatingCache<K,V>
listener
- must not be null.public V put(K key, V value, org.infinispan.metadata.Metadata metadata)
put
in class AbstractDelegatingAdvancedCache<K,V>
public org.infinispan.util.concurrent.NotifyingFuture<V> putAsync(K key, V value, org.infinispan.metadata.Metadata metadata)
putAsync
in class AbstractDelegatingAdvancedCache<K,V>
public V putIfAbsent(K key, V value, org.infinispan.metadata.Metadata metadata)
putIfAbsent
in class AbstractDelegatingAdvancedCache<K,V>
public boolean replace(K key, V oldValue, V value, org.infinispan.metadata.Metadata metadata)
replace
in class AbstractDelegatingAdvancedCache<K,V>
public V replace(K key, V value, org.infinispan.metadata.Metadata metadata)
replace
in class AbstractDelegatingAdvancedCache<K,V>
public org.infinispan.container.entries.CacheEntry getCacheEntry(K key)
getCacheEntry
in class AbstractDelegatingAdvancedCache<K,V>