Interface RMapCacheAsync<K,V>
-
- Type Parameters:
K
- keyV
- value
- All Superinterfaces:
RExpirableAsync
,RMapAsync<K,V>
,RObjectAsync
- All Known Subinterfaces:
RMapCache<K,V>
- All Known Implementing Classes:
RedissonMapCache
,RedissonTransactionalMapCache
public interface RMapCacheAsync<K,V> extends RMapAsync<K,V>
Map-based cache with ability to set TTL for each entry via
RMapCache.put(Object, Object, long, TimeUnit)
orRMapCache.putIfAbsent(Object, Object, long, TimeUnit)
And therefore has an complex lua-scripts inside.Current redis implementation doesnt have map entry eviction functionality. Thus entries are checked for TTL expiration during any key/value/entry read operation. If key/value/entry expired then it doesn't returns. Expired tasks cleaned by
EvictionScheduler
. This scheduler deletes expired entries in time interval between 5 seconds to 2 hours.If eviction is not required then it's better to use
RedissonMap
.- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RFuture<Boolean>
fastPutAsync(K key, V value, long ttl, TimeUnit unit)
Stores value mapped by key with specified time to live.RFuture<Boolean>
fastPutAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.RFuture<Boolean>
fastPutIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
If the specified key is not already associated with a value, associate it with the given value.RFuture<V>
getWithTTLOnlyAsync(K key)
Returns the value mapped by definedkey
ornull
if value is absent.RFuture<Void>
putAllAsync(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
Associates the specifiedvalue
with the specifiedkey
in batch.RFuture<V>
putAsync(K key, V value, long ttl, TimeUnit unit)
Stores value mapped by key with specified time to live.RFuture<V>
putAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.RFuture<V>
putIfAbsentAsync(K key, V value, long ttl, TimeUnit unit)
If the specified key is not already associated with a value, associate it with the given value.RFuture<V>
putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
If the specified key is not already associated with a value, associate it with the given value.RFuture<Long>
remainTimeToLiveAsync(K key)
Remaining time to live of map entry associated with akey
.RFuture<Void>
setMaxSizeAsync(int maxSize)
Sets max size of the map and overrides current value.RFuture<Void>
setMaxSizeAsync(int maxSize, EvictionMode mode)
Sets max size of the map and overrides current value.RFuture<Integer>
sizeAsync()
Returns the number of entries in cache.RFuture<Boolean>
trySetMaxSizeAsync(int maxSize)
Tries to set max size of the map.RFuture<Boolean>
trySetMaxSizeAsync(int maxSize, EvictionMode mode)
Tries to set max size of the map.RFuture<Boolean>
updateEntryExpirationAsync(K key, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Updates time to live and max idle time of specified entry by key.-
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RMapAsync
addAndGetAsync, computeAsync, computeIfAbsentAsync, computeIfPresentAsync, containsKeyAsync, containsValueAsync, fastPutAsync, fastPutIfAbsentAsync, fastPutIfExistsAsync, fastRemoveAsync, fastReplaceAsync, getAllAsync, getAsync, loadAllAsync, loadAllAsync, mergeAsync, putAllAsync, putAllAsync, putAsync, putIfAbsentAsync, putIfExistsAsync, randomEntriesAsync, randomKeysAsync, readAllEntrySetAsync, readAllKeySetAsync, readAllMapAsync, readAllValuesAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, valueSizeAsync
-
Methods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
-
-
-
Method Detail
-
setMaxSizeAsync
RFuture<Void> setMaxSizeAsync(int maxSize)
Sets max size of the map and overrides current value. Superfluous elements are evicted using LRU algorithm by default.- Parameters:
maxSize
- - max size- Returns:
- void
-
setMaxSizeAsync
RFuture<Void> setMaxSizeAsync(int maxSize, EvictionMode mode)
Sets max size of the map and overrides current value. Superfluous elements are evicted using defined algorithm.- Parameters:
maxSize
- - max sizemode
- - eviction mode- Returns:
- void
-
trySetMaxSizeAsync
RFuture<Boolean> trySetMaxSizeAsync(int maxSize)
Tries to set max size of the map. Superfluous elements are evicted using LRU algorithm by default.- Parameters:
maxSize
- - max size- Returns:
true
if max size has been successfully set, otherwisefalse
.
-
trySetMaxSizeAsync
RFuture<Boolean> trySetMaxSizeAsync(int maxSize, EvictionMode mode)
Tries to set max size of the map. Superfluous elements are evicted using defined algorithm.- Parameters:
maxSize
- - max sizemode
- - eviction mode- Returns:
true
if max size has been successfully set, otherwisefalse
.
-
putIfAbsentAsync
RFuture<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit unit)
If the specified key is not already associated with a value, associate it with the given value.Stores value mapped by key with specified time to live. Entry expires after specified time to live. If the map previously contained a mapping for the key, the old value is replaced by the specified value.
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.unit
- - time unit- Returns:
- previous associated value
-
putIfAbsentAsync
RFuture<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
If the specified key is not already associated with a value, associate it with the given value.Stores value mapped by key with specified time to live and max idle time. Entry expires when specified time to live or max idle time has expired.
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry. If0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unitif
maxIdleTime
andttl
params are equal to0
then entry stores infinitely.- Returns:
- previous associated value
-
putAsync
RFuture<V> putAsync(K key, V value, long ttl, TimeUnit unit)
Stores value mapped by key with specified time to live. Entry expires after specified time to live. If the map previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.unit
- - time unit- Returns:
- previous associated value
-
putAsync
RFuture<V> putAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time. Entry expires when specified time to live or max idle time has expired.If the map previously contained a mapping for the key, the old value is replaced by the specified value.
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry. If0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unitif
maxIdleTime
andttl
params are equal to0
then entry stores infinitely.- Returns:
- previous associated value
-
putAllAsync
RFuture<Void> putAllAsync(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
Associates the specifiedvalue
with the specifiedkey
in batch.If
MapWriter
is defined then new map entries are stored in write-through mode.- Parameters:
map
- - mappings to be stored in this mapttl
- - time to live for all key\value entries. If0
then stores infinitely.ttlUnit
- - time unit- Returns:
- void
-
fastPutAsync
RFuture<Boolean> fastPutAsync(K key, V value, long ttl, TimeUnit unit)
Stores value mapped by key with specified time to live. Entry expires after specified time to live.If the map previously contained a mapping for the key, the old value is replaced by the specified value.
Works faster than usual
putAsync(Object, Object, long, TimeUnit)
as it not returns previous value.- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.unit
- - time unit- Returns:
true
if key is a new key in the hash and value was set.false
if key already exists in the hash and the value was updated.
-
fastPutAsync
RFuture<Boolean> fastPutAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time. Entry expires when specified time to live or max idle time has expired.If the map previously contained a mapping for the key, the old value is replaced by the specified value.
Works faster than usual
putAsync(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry. If0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unitif
maxIdleTime
andttl
params are equal to0
then entry stores infinitely.- Returns:
true
if key is a new key in the hash and value was set.false
if key already exists in the hash and the value was updated.
-
fastPutIfAbsentAsync
RFuture<Boolean> fastPutIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
If the specified key is not already associated with a value, associate it with the given value.Stores value mapped by key with specified time to live and max idle time. Entry expires when specified time to live or max idle time has expired.
Works faster than usual
putIfAbsentAsync(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry. If0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unitif
maxIdleTime
andttl
params are equal to0
then entry stores infinitely.- Returns:
true
if key is a new key in the hash and value was set.false
if key already exists in the hash
-
updateEntryExpirationAsync
RFuture<Boolean> updateEntryExpirationAsync(K key, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Updates time to live and max idle time of specified entry by key. Entry expires when specified time to live or max idle time was reached.Returns
false
if entry already expired or doesn't exist, otherwise returnstrue
.- Parameters:
key
- - map keyttl
- - time to live for key\value entry. If0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry. If0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unitif
maxIdleTime
andttl
params are equal to0
then entry stores infinitely.- Returns:
- returns
false
if entry already expired or doesn't exist, otherwise returnstrue
.
-
getWithTTLOnlyAsync
RFuture<V> getWithTTLOnlyAsync(K key)
Returns the value mapped by definedkey
ornull
if value is absent.If map doesn't contain value for specified key and
MapLoader
is defined then value will be loaded in read-through mode.Idle time of entry is not taken into account. Entry last access time isn't modified if map limited by size.
- Parameters:
key
- the key- Returns:
- the value mapped by defined
key
ornull
if value is absent
-
sizeAsync
RFuture<Integer> sizeAsync()
Returns the number of entries in cache. This number can reflects expired entries too due to non realtime cleanup process.
-
-