Package org.infinispan.commons.api
Interface BasicCache<K,V>
-
- All Superinterfaces:
AsyncCache<K,V>
,ConcurrentMap<K,V>
,Lifecycle
,Map<K,V>
- All Known Subinterfaces:
AdvancedCache<K,V>
,Cache<K,V>
,SecureCache<K,V>
- All Known Implementing Classes:
AbstractDelegatingAdvancedCache
,org.infinispan.cache.impl.AbstractDelegatingAdvancedCache
,AbstractDelegatingCache
,org.infinispan.cache.impl.AbstractDelegatingCache
public interface BasicCache<K,V> extends AsyncCache<K,V>, ConcurrentMap<K,V>, Lifecycle
BasicCache provides the common building block for the two different types of caches that Infinispan provides: embedded and remote. For convenience, BasicCache extendsConcurrentMap
and implements all methods accordingly, although methods likeMap.keySet()
,Map.values()
andMap.entrySet()
are expensive (prohibitively so when using a distributed cache) and frequent use of these methods is not recommended. Other methods such asMap.size()
provide an approximation-only, and should not be relied on for an accurate picture as to the size of the entire, distributed cache. Remote nodes are not queried and in-fly transactions are not taken into account, even ifMap.size()
is invoked from within such a transaction. Also, like manyConcurrentMap
implementations, BasicCache does not support the use of null keys or values.Unsupported operations
Please see the Infinispan documentation and/or the 5 Minute Usage Tutorial for more details.- Since:
- 5.1
- Author:
- Mircea.Markus@jboss.com, Manik Surtani, Galder ZamarreƱo, Tristan Tarrant
- See Also:
- Infinispan documentation, 5 Minute Usage Tutorial
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description V
compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan parameters.V
compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.V
computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit)
An overloaded form ofConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan parameters.V
computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan and maxIdleTime parameters.V
computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
An overloaded form ofConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan parameters.V
computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.String
getName()
Retrieves the name of the cacheString
getVersion()
Retrieves the version of InfinispanV
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
merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
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 ofput(Object, Object)
, which takes in lifespan parameters.V
put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofput(Object, Object)
, which takes in lifespan parameters.void
putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
An overloaded form ofMap.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 ofMap.putAll(Map)
, which takes in lifespan parameters.V
putIfAbsent(K key, V value, long lifespan, TimeUnit unit)
An overloaded form ofConcurrentMap.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 ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.V
remove(Object key)
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
replace(K key, V value, long lifespan, TimeUnit unit)
An overloaded form ofConcurrentMap.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 ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.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.boolean
replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.-
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, putAllAsync, putAllAsync, putAsync, putAsync, putAsync, putIfAbsentAsync, putIfAbsentAsync, putIfAbsentAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync, replaceAsync
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
getName
String getName()
Retrieves the name of the cache- Returns:
- the name of the cache
-
getVersion
String getVersion()
Retrieves the version of Infinispan- Returns:
- a version string
-
put
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. avoiding needless remote or network calls).
-
put
V put(K key, V value, long lifespan, TimeUnit unit)
An overloaded form ofput(Object, Object)
, which takes in lifespan parameters.- 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
V putIfAbsent(K key, V value, long lifespan, TimeUnit unit)
An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.- 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
void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit unit)
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.- Parameters:
map
- map containing mappings to enterlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.unit
- unit of measurement for the lifespan
-
replace
V replace(K key, V value, long lifespan, TimeUnit unit)
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.- 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
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.- 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
-
put
V put(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofput(Object, Object)
, which takes in lifespan parameters.- Parameters:
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 time- Returns:
- the value being replaced, or null if nothing is being replaced.
-
putIfAbsent
V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.putIfAbsent(Object, Object)
, which takes in lifespan parameters.- Parameters:
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 time- Returns:
- the value being replaced, or null if nothing is being replaced.
-
putAll
void putAll(Map<? extends K,? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
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.- Parameters:
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 time
-
replace
V replace(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.replace(Object, Object)
, which takes in lifespan parameters.- Parameters:
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 time- Returns:
- the value being replaced, or null if nothing is being replaced.
-
replace
boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.replace(Object, Object, Object)
, which takes in lifespan parameters.- Parameters:
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 time- Returns:
- true if the value was replaced, false otherwise
-
merge
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.- 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
-
merge
V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.merge(Object, Object, BiFunction)
which takes in lifespan parameters.- 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 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 time- Returns:
- the merged value that was stored under key
-
compute
V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan parameters.- Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the computed value that was stored under key
-
compute
V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.compute(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.- Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under keylifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the computed value that was stored under key
-
computeIfPresent
V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit)
An overloaded form ofConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan parameters.- Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under key, if such existslifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the computed value that was stored under key
-
computeIfPresent
V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.computeIfPresent(Object, BiFunction)
which takes in lifespan and maxIdleTime parameters.- Parameters:
key
- key to useremappingFunction
- function to use to compute and store the value under key, if such existslifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the computed value that was stored under key
-
computeIfAbsent
V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit)
An overloaded form ofConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan parameters.- Parameters:
key
- key to usemappingFunction
- function to use to compute and store the value under key, if the key is absentlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespan- Returns:
- the computed value that was stored under key
-
computeIfAbsent
V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit)
An overloaded form ofConcurrentMap.computeIfAbsent(Object, Function)
which takes in lifespan and maxIdleTime parameters.- Parameters:
key
- key to usemappingFunction
- function to use to compute and store the value under key, if the key is absentlifespan
- lifespan of the entry. Negative values are interpreted as unlimited lifespan.lifespanUnit
- time unit for lifespanmaxIdleTime
- the maximum amount of time this key is allowed to be idle for before it is considered as expiredmaxIdleTimeUnit
- time unit for max idle time- Returns:
- the computed value that was stored under key
-
remove
V remove(Object key)
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).
-
-