Package org.infinispan.cache.impl
Class CacheSupport<K,V>
- java.lang.Object
-
- org.infinispan.cache.impl.CacheSupport<K,V>
-
- All Implemented Interfaces:
ConcurrentMap<K,V>
,Map<K,V>
,org.infinispan.commons.api.AsyncCache<K,V>
,org.infinispan.commons.api.BasicCache<K,V>
,org.infinispan.commons.api.Lifecycle
public abstract class CacheSupport<K,V> extends Object implements org.infinispan.commons.api.BasicCache<K,V>
- Since:
- 4.1
- Author:
- Mircea.Markus@jboss.com
-
-
Field Summary
Fields Modifier and Type Field Description protected long
defaultLifespan
protected long
defaultMaxIdleTime
-
Constructor Summary
Constructors Modifier Constructor Description protected
CacheSupport()
protected
CacheSupport(long defaultLifespan, long defaultMaxIdleTime)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description V
merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
V
merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
An overloaded form ofConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.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 theFlag.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 ofBasicCache.put(Object, Object)
, which takes in lifespan parameters.void
putAll(Map<? extends K,? extends V> map)
void
putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
An overloaded form ofMap.putAll(Map)
, which takes in lifespan parameters.CompletableFuture<Void>
putAllAsync(Map<? extends K,? extends V> data)
Asynchronous version ofMap.putAll(Map)
.CompletableFuture<Void>
putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)
Asynchronous version ofBasicCache.putAll(Map, long, TimeUnit)
.CompletableFuture<V>
putAsync(K key, V value)
Asynchronous version ofBasicCache.put(Object, Object)
.CompletableFuture<V>
putAsync(K key, V value, long lifespan, TimeUnit unit)
Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit)
.V
putIfAbsent(K key, V value)
V
putIfAbsent(K key, V value, long lifespan, TimeUnit unit)
An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.CompletableFuture<V>
putIfAbsentAsync(K key, V value)
Asynchronous version ofConcurrentMap.putIfAbsent(Object, Object)
.CompletableFuture<V>
putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit)
Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit)
.V
replace(K key, V value)
V
replace(K key, V value, long lifespan, TimeUnit unit)
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.boolean
replace(K key, V oldValue, V newValue)
boolean
replace(K key, V oldValue, V value, long lifespan, TimeUnit unit)
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.CompletableFuture<V>
replaceAsync(K key, V value)
Asynchronous version ofConcurrentMap.replace(Object, Object)
.CompletableFuture<V>
replaceAsync(K key, V value, long lifespan, TimeUnit unit)
Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit)
.CompletableFuture<Boolean>
replaceAsync(K key, V oldValue, V newValue)
Asynchronous version ofConcurrentMap.replace(Object, Object, Object)
.CompletableFuture<Boolean>
replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit)
Asynchronous version ofBasicCache.replace(Object, Object, Object, long, TimeUnit)
.protected abstract void
set(K key, V value)
This is intentionally a non-public method meant as an integration point for bytecode manipulation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.commons.api.AsyncCache
clearAsync, computeAsync, computeAsync, computeAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfAbsentAsync, computeIfPresentAsync, computeIfPresentAsync, computeIfPresentAsync, containsKeyAsync, getAllAsync, getAsync, mergeAsync, mergeAsync, mergeAsync, putAllAsync, putAsync, putIfAbsentAsync, removeAsync, removeAsync, replaceAsync, replaceAsync
-
Methods inherited from interface org.infinispan.commons.api.BasicCache
compute, compute, computeIfAbsent, computeIfAbsent, computeIfPresent, computeIfPresent, getName, getVersion, merge, put, putAll, putIfAbsent, remove, replace, replace
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, remove, replaceAll
-
-
-
-
Method Detail
-
put
public final V put(K key, V value)
Description copied from interface:org.infinispan.commons.api.BasicCache
If the return value of this operation will be ignored by the application, the user is strongly encouraged to use theFlag.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).
-
set
protected abstract void set(K key, V value)
This is intentionally a non-public method meant as an integration point for bytecode manipulation. Don't remove or alter the signature even if it might look like unreachable code. Implementors should perform a put operation but optimizing it as return values are not required.- Since:
- 5.0
-
putAsync
public final CompletableFuture<V> putAsync(K key, V value)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.put(Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
putIfAbsent
public final V putIfAbsent(K key, V value)
- Specified by:
putIfAbsent
in interfaceConcurrentMap<K,V>
- Specified by:
putIfAbsent
in interfaceMap<K,V>
-
putAsync
public final CompletableFuture<V> putAsync(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.put(Object, Object, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
putAllAsync
public final CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofMap.putAll(Map)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
putAllAsync
public final CompletableFuture<Void> putAllAsync(Map<? extends K,? extends V> data, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.putAll(Map, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
putIfAbsentAsync
public final CompletableFuture<V> putIfAbsentAsync(K key, V value)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofConcurrentMap.putIfAbsent(Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
putIfAbsentAsync
public final CompletableFuture<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.putIfAbsent(Object, Object, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
replaceAsync
public final CompletableFuture<V> replaceAsync(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.replace(Object, Object, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
replaceAsync
public final CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofConcurrentMap.replace(Object, Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
replaceAsync
public final CompletableFuture<V> replaceAsync(K key, V value)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofConcurrentMap.replace(Object, Object)
. This method does not block on remote calls, even if your cache mode is synchronous.
-
replaceAsync
public final CompletableFuture<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.AsyncCache
Asynchronous version ofBasicCache.replace(Object, Object, Object, long, TimeUnit)
. This method does not block on remote calls, even if your cache mode is synchronous.- Specified by:
replaceAsync
in interfaceorg.infinispan.commons.api.AsyncCache<K,V>
- Parameters:
key
- key to removeoldValue
- value to overwritenewValue
- value to storelifespan
- lifespan of entryunit
- time unit for lifespan- Returns:
- a future containing a boolean, indicating whether the entry was replaced or not
-
put
public final V put(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCache
An overloaded form ofBasicCache.put(Object, Object)
, which takes in lifespan parameters.- Specified by:
put
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespan- Returns:
- the value being replaced, or null if nothing is being replaced.
-
putIfAbsent
public final V putIfAbsent(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCache
An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.- Specified by:
putIfAbsent
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespan- Returns:
- the value being replaced, or null if nothing is being replaced.
-
putAll
public final void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCache
An overloaded form ofMap.putAll(Map)
, which takes in lifespan parameters. Note that the lifespan is applied to all mappings in the map passed in.
-
replace
public final V replace(K key, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCache
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.- Specified by:
replace
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Parameters:
key
- key to usevalue
- value to storelifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespan- Returns:
- the value being replaced, or null if nothing is being replaced.
-
replace
public final boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit unit)
Description copied from interface:org.infinispan.commons.api.BasicCache
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.- Specified by:
replace
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Parameters:
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 lifespan- Returns:
- true if the value was replaced, false otherwise
-
merge
public final V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
-
merge
public final V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
Description copied from interface:org.infinispan.commons.api.BasicCache
An overloaded form ofConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.- Specified by:
merge
in interfaceorg.infinispan.commons.api.BasicCache<K,V>
- Parameters:
key
- key to usevalue
- new value to merge with existing valueremappingFunction
- function to use to merge new and existing values into a merged value to store under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the merged value that was stored under key
-
-