public abstract class AbstractDelegatingCache<K,V> extends Object implements Cache<K,V>
Cache
argument, to which each method call is delegated. One can extend this class and override the method sub-set it is
interested in. There is also an similar implementation for AdvancedCache
: AbstractDelegatingAdvancedCache
.AbstractDelegatingAdvancedCache
Constructor and Description |
---|
AbstractDelegatingCache(Cache<K,V> cache) |
Modifier and Type | Method and Description |
---|---|
<C> void |
addFilteredListener(Object listener,
CacheEventFilter<? super K,? super V> filter,
CacheEventConverter<? super K,? super V,C> converter,
Set<Class<? extends Annotation>> filterAnnotations)
Registers a listener limiting the cache-entry specific events only to
annotations that are passed in as parameter.
|
void |
addListener(Object listener)
Adds a listener to the component.
|
<C> void |
addListener(Object listener,
CacheEventFilter<? super K,? super V> filter,
CacheEventConverter<? super K,? super V,C> converter)
Registers a listener that will be notified on events that pass the filter condition.
|
void |
addListener(Object listener,
KeyFilter<? super K> filter)
Adds a listener to the component.
|
void |
clear()
Removes all mappings from the cache.
|
org.infinispan.commons.util.concurrent.NotifyingFuture<Void> |
clearAsync() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
void |
endBatch(boolean successful) |
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) |
AdvancedCache<K,V> |
getAdvancedCache() |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
getAsync(K key) |
Configuration |
getCacheConfiguration() |
EmbeddedCacheManager |
getCacheManager()
Retrieves the cache manager responsible for creating this cache instance.
|
Cache<K,V> |
getDelegate() |
Set<Object> |
getListeners() |
String |
getName() |
ComponentStatus |
getStatus() |
String |
getVersion() |
boolean |
isEmpty() |
CacheSet<K> |
keySet()
Returns a set view of the keys contained in this cache and cache loader across the entire cluster.
|
V |
put(K key,
V value) |
V |
put(K key,
V value,
long lifespan,
TimeUnit unit) |
V |
put(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit) |
void |
putAll(Map<? extends K,? extends V> t) |
void |
putAll(Map<? extends K,? extends V> map,
long lifespan,
TimeUnit unit) |
void |
putAll(Map<? extends K,? extends V> map,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<Void> |
putAllAsync(Map<? extends K,? extends V> data) |
org.infinispan.commons.util.concurrent.NotifyingFuture<Void> |
putAllAsync(Map<? extends K,? extends V> data,
long lifespan,
TimeUnit unit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<Void> |
putAllAsync(Map<? extends K,? extends V> data,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
putAsync(K key,
V value) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
putAsync(K key,
V value,
long lifespan,
TimeUnit unit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
putAsync(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit) |
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. |
V |
putIfAbsent(K key,
V value) |
V |
putIfAbsent(K key,
V value,
long lifespan,
TimeUnit unit) |
V |
putIfAbsent(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
putIfAbsentAsync(K key,
V value) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
putIfAbsentAsync(K key,
V value,
long lifespan,
TimeUnit unit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
putIfAbsentAsync(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit) |
V |
remove(Object key) |
boolean |
remove(Object key,
Object value) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
removeAsync(Object key) |
org.infinispan.commons.util.concurrent.NotifyingFuture<Boolean> |
removeAsync(Object key,
Object value) |
void |
removeListener(Object listener)
Removes a listener from the component.
|
V |
replace(K key,
V value) |
V |
replace(K key,
V value,
long lifespan,
TimeUnit unit) |
V |
replace(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit) |
boolean |
replace(K key,
V oldValue,
V newValue) |
boolean |
replace(K key,
V oldValue,
V value,
long lifespan,
TimeUnit unit) |
boolean |
replace(K key,
V oldValue,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdleTime,
TimeUnit maxIdleTimeUnit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
replaceAsync(K key,
V value) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
replaceAsync(K key,
V value,
long lifespan,
TimeUnit unit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<V> |
replaceAsync(K key,
V value,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue) |
org.infinispan.commons.util.concurrent.NotifyingFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
long lifespan,
TimeUnit unit) |
org.infinispan.commons.util.concurrent.NotifyingFuture<Boolean> |
replaceAsync(K key,
V oldValue,
V newValue,
long lifespan,
TimeUnit lifespanUnit,
long maxIdle,
TimeUnit maxIdleUnit) |
protected void |
set(K key,
V value)
Don't remove.
|
int |
size()
Returns a count of all elements in this cache and cache loader across the entire cluster.
|
void |
start() |
boolean |
startBatch() |
void |
stop() |
String |
toString() |
CacheCollection<V> |
values()
Returns a collection view of the values contained in this cache across the entire cluster.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
public void putForExternalRead(K key, V value)
Cache
ConcurrentMap.putIfAbsent(Object, Object)
)
putForExternalRead
in interface Cache<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.public void putForExternalRead(K key, V value, long lifespan, TimeUnit unit)
Cache
#putForExternalRead(K, V)
, which takes in lifespan parameters.putForExternalRead
in interface Cache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespanpublic void putForExternalRead(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
Cache
#putForExternalRead(K, V)
, which takes in lifespan parameters.putForExternalRead
in interface Cache<K,V>
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdle
- the maximum amount of time this key is allowed to be idle for before it is considered as
expiredmaxIdleUnit
- time unit for max idle timepublic 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 Configuration getCacheConfiguration()
getCacheConfiguration
in interface Cache<K,V>
public boolean startBatch()
startBatch
in interface org.infinispan.commons.api.BatchingCache
public void endBatch(boolean successful)
endBatch
in interface org.infinispan.commons.api.BatchingCache
public String getName()
public String getVersion()
public EmbeddedCacheManager getCacheManager()
Cache
getCacheManager
in interface Cache<K,V>
protected void set(K key, V value)
org.infinispan.cache.impl.CacheSupport#set(Object, Object)}
public V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
public V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
public void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
public V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
public boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> putAsync(K key, V value, long lifespan, TimeUnit unit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data)
public org.infinispan.commons.util.concurrent.NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<Void> clearAsync()
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> putIfAbsentAsync(K key, V value)
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> removeAsync(Object key)
public org.infinispan.commons.util.concurrent.NotifyingFuture<Boolean> removeAsync(Object key, Object value)
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> replaceAsync(K key, V value)
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit unit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
public org.infinispan.commons.util.concurrent.NotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit)
public org.infinispan.commons.util.concurrent.NotifyingFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit)
public AdvancedCache<K,V> getAdvancedCache()
getAdvancedCache
in interface Cache<K,V>
public ComponentStatus getStatus()
public V putIfAbsent(K key, V value)
putIfAbsent
in interface ConcurrentMap<K,V>
putIfAbsent
in interface Map<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 boolean containsKey(Object key)
containsKey
in interface Map<K,V>
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
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 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 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 void start()
start
in interface org.infinispan.commons.api.Lifecycle
public void stop()
stop
in interface org.infinispan.commons.api.Lifecycle
public void addListener(Object listener)
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 Listenable
listener
- must not be null.public void addListener(Object listener, KeyFilter<? super K> filter)
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 FilteringListenable<K,V>
listener
- must not be null.public <C> void addListener(Object listener, CacheEventFilter<? super K,? super V> filter, CacheEventConverter<? super K,? super V,C> converter)
FilteringListenable
Some implementations may provide optimizations when a
CacheEventFilterConverter
is provided as both arguments
to the filter and converter arguments. Note the provided object must have reference equality ie. (==)
to be recognized. This allows for the filter and conversion step to take place in the same method call reducing
possible overhead.
addListener
in interface FilteringListenable<K,V>
C
- The type of the resultant value after being convertedlistener
- The listener to callback upon event notifications. Must not be null.filter
- The filter to see if the notification should be sent to the listener. Can be null.converter
- The converter to apply to the entry before being sent to the listener. Can be null.public void removeListener(Object listener)
Listenable
removeListener
in interface Listenable
listener
- listener to remove. Must not be null.public Set<Object> getListeners()
getListeners
in interface Listenable
public <C> void addFilteredListener(Object listener, CacheEventFilter<? super K,? super V> filter, CacheEventConverter<? super K,? super V,C> converter, Set<Class<? extends Annotation>> filterAnnotations)
FilteringListenable
CacheEntryCreated
and CacheEntryModified
,
and filtered annotations contains only CacheEntryCreated
,
then the listener will be registered only for CacheEntryCreated
callbacks.
Callback filtering only applies to CacheEntryCreated
,
CacheEntryModified
, CacheEntryRemoved
and CacheEntryExpired
annotations.
If the listener contains other annotations, these are preserved.
This methods enables dynamic registration of listener interests at
runtime without the need to create several different listener classes.addFilteredListener
in interface FilteringListenable<K,V>
C
- The type of the resultant value after being convertedlistener
- The listener to callback upon event notifications. Must not be null.filter
- The filter to see if the notification should be sent to the listener. Can be null.converter
- The converter to apply to the entry before being sent to the listener. Can be null.filterAnnotations
- cache-entry annotations to allow listener to be registered on. Must not be null.Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.