Class RedissonMapCache<K,V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonMap<K,V>
-
- org.redisson.RedissonMapCache<K,V>
-
- Type Parameters:
K
- keyV
- value
- All Implemented Interfaces:
ConcurrentMap<K,V>
,Map<K,V>
,RDestroyable
,RExpirable
,RExpirableAsync
,RMap<K,V>
,RMapAsync<K,V>
,RMapCache<K,V>
,RMapCacheAsync<K,V>
,RObject
,RObjectAsync
- Direct Known Subclasses:
RedissonTransactionalMapCache
public class RedissonMapCache<K,V> extends RedissonMap<K,V> implements RMapCache<K,V>
Map-based cache with ability to set TTL for each entry via
put(Object, Object, long, TimeUnit)
orputIfAbsent(Object, Object, long, TimeUnit)
methods. 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 and clean task runs asynchronous. Clean task deletes removes 100 expired entries at once. In addition there is
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
object.- Author:
- Nikita Koksharov
-
-
Field Summary
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Constructor Description RedissonMapCache(Codec codec, EvictionScheduler evictionScheduler, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options, WriteBehindService writeBehindService)
RedissonMapCache(EvictionScheduler evictionScheduler, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options, WriteBehindService writeBehindService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description V
addAndGet(K key, Number value)
Adds the givendelta
to the current value by mappedkey
.protected RFuture<V>
addAndGetOperationAsync(K key, Number value)
int
addListener(MapEntryListener listener)
Adds map entry listenervoid
clear()
boolean
clearExpire()
Clear an expire timeout or expire date for object.RFuture<Boolean>
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.protected RFuture<Boolean>
clearExpireAsync(String... keys)
RFuture<Boolean>
containsKeyAsync(Object key)
Returnstrue
if this map contains map entry mapped by specifiedkey
, otherwisefalse
RFuture<Boolean>
containsValueAsync(Object value)
Returnstrue
if this map contains any map entry with specifiedvalue
, otherwisefalse
RFuture<Boolean>
deleteAsync()
Delete object in async modevoid
destroy()
Destroys object when it's not necessary anymore.boolean
expire(long timeToLive, TimeUnit timeUnit)
Set a timeout for object.boolean
expire(Instant instant)
Set an expire date for object.RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit)
Set a timeout for object in async mode.protected RFuture<Boolean>
expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
RFuture<Boolean>
expireAsync(Instant instant)
Set an expire date for object.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
expireAt(Date timestamp)
UseRExpirable.expire(Instant)
insteadRFuture<Boolean>
expireAtAsync(long timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadprotected RFuture<Boolean>
expireAtAsync(long timestamp, String... keys)
RFuture<Boolean>
expireAtAsync(Date timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadboolean
fastPut(K key, V value, long ttl, TimeUnit ttlUnit)
Stores value mapped by key with specified time to live.boolean
fastPut(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>
fastPutAsync(K key, V value, long ttl, TimeUnit ttlUnit)
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.boolean
fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
If the specified key is not already associated with a value, associate it with the given value.boolean
fastPutIfAbsent(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<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.protected RFuture<Boolean>
fastPutIfAbsentOperationAsync(K key, V value)
protected RFuture<Boolean>
fastPutIfExistsOperationAsync(K key, V value)
protected RFuture<Boolean>
fastPutOperationAsync(K key, V value)
protected RFuture<Boolean>
fastPutOperationAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
protected RFuture<Long>
fastRemoveOperationAsync(K... keys)
protected RFuture<List<Long>>
fastRemoveOperationBatchAsync(K... keys)
protected RFuture<Boolean>
fastReplaceOperationAsync(K key, V value)
RFuture<Map<K,V>>
getAllOperationAsync(Set<K> keys)
RFuture<V>
getOperationAsync(K key)
V
getWithTTLOnly(K key)
Returns the value mapped by definedkey
ornull
if value is absent.RFuture<V>
getWithTTLOnlyAsync(K key)
Returns the value mapped by definedkey
ornull
if value is absent.V
put(K key, V value, long ttl, TimeUnit unit)
Stores value mapped by key with specified time to live.V
put(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.void
putAll(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
Associates the specifiedvalue
with the specifiedkey
in batch.RFuture<Void>
putAllAsync(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
Associates the specifiedvalue
with the specifiedkey
in batch.protected RFuture<Void>
putAllOperationAsync(Map<? extends K,? extends V> map)
RFuture<V>
putAsync(K key, V value, long ttl, TimeUnit ttlUnit)
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.V
putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
If the specified key is not already associated with a value, associate it with the given value.V
putIfAbsent(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>
putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit)
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.protected RFuture<V>
putIfAbsentOperationAsync(K key, V value)
protected RFuture<V>
putIfExistsOperationAsync(K key, V value)
protected RFuture<V>
putOperationAsync(K key, V value)
protected RFuture<V>
putOperationAsync(K key, V value, long ttlTimeout, long maxIdleTimeout, long maxIdleDelta, long ttlTimeoutDelta)
RFuture<Map<K,V>>
randomEntriesAsync(int count)
Returns random map entries from this map limited bycount
RFuture<Set<K>>
randomKeysAsync(int count)
Returns random keys from this map limited bycount
RFuture<Set<Map.Entry<K,V>>>
readAllEntrySetAsync()
Read all map entries at onceRFuture<Set<K>>
readAllKeySetAsync()
Read all keys at onceRFuture<Map<K,V>>
readAllMapAsync()
Read all map as local instance at onceRFuture<Collection<V>>
readAllValuesAsync()
Read all values at oncelong
remainTimeToLive()
Remaining time to live of Redisson object that has a timeoutlong
remainTimeToLive(K key)
Remaining time to live of map entry associated with akey
.RFuture<Long>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutRFuture<Long>
remainTimeToLiveAsync(K key)
Remaining time to live of map entry associated with akey
.void
removeListener(int listenerId)
Removes object event listenerprotected RFuture<Boolean>
removeOperationAsync(Object key, Object value)
protected RFuture<V>
removeOperationAsync(K key)
protected RFuture<V>
replaceOperationAsync(K key, V value)
protected RFuture<Boolean>
replaceOperationAsync(K key, V oldValue, V newValue)
ScanResult<Map.Entry<Object,Object>>
scanIterator(String name, RedisClient client, long startPos, String pattern, int count)
RFuture<ScanResult<Map.Entry<Object,Object>>>
scanIteratorAsync(String name, RedisClient client, long startPos, String pattern, int count)
void
setMaxSize(int maxSize)
Sets max size of the map and overrides current value.void
setMaxSize(int maxSize, EvictionMode mode)
Sets max size of the map and overrides current value.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<Long>
sizeInMemoryAsync()
Returns bytes amount used by object in Redis memory.boolean
trySetMaxSize(int maxSize)
Tries to set max size of the map.boolean
trySetMaxSize(int maxSize, EvictionMode mode)
Tries to set max size of the map.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.boolean
updateEntryExpiration(K key, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Updates time to live and max idle time of specified entry by key.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 class org.redisson.RedissonMap
addAndGetAsync, checkKey, checkValue, compute, computeAsync, computeIfAbsent, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, containsKey, containsKeyAsync, containsValue, entryIterator, entrySet, entrySet, entrySet, entrySet, equals, fastPut, fastPutAsync, fastPutIfAbsent, fastPutIfAbsentAsync, fastPutIfExists, fastPutIfExistsAsync, fastRemove, fastRemoveAsync, fastReplace, fastReplaceAsync, get, getAll, getAllAsync, getAsync, getCountDownLatch, getFairLock, getLock, getPermitExpirableSemaphore, getReadWriteLock, getSemaphore, hashCode, hasNoLoader, hasNoWriter, isEmpty, keyIterator, keySet, keySet, keySet, keySet, loadAll, loadAll, loadAllAsync, loadAllAsync, loadAllAsync, loadValue, mapReduce, mapWriterFuture, mapWriterFuture, merge, mergeAsync, put, putAll, putAll, putAllAsync, putAllAsync, putAsync, putIfAbsent, putIfAbsentAsync, putIfExists, putIfExistsAsync, randomEntries, randomKeys, readAllEntrySet, readAllKeySet, readAllMap, readAllValues, remove, remove, removeAsync, removeAsync, replace, replace, replaceAsync, replaceAsync, size, sizeAsync, valueIterator, values, values, values, values, valueSize, valueSizeAsync
-
Methods inherited from class org.redisson.RedissonObject
addListener, addListener, addListenerAsync, addListenerAsync, copy, copyAsync, delete, deleteAsync, dump, dumpAsync, encode, encode, encode, encode, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, removeListenerAsync, removeListenersAsync, rename, renameAsync, renamenx, renamenxAsync, restore, restore, restoreAndReplace, restoreAndReplace, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, setName, sizeInMemory, sizeInMemoryAsync, sizeInMemoryAsync, suffixName, toSeconds, toStream, touch, touchAsync, unlink, unlinkAsync
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expireAt, expireAt, remainTimeToLive
-
Methods inherited from interface org.redisson.api.RExpirableAsync
expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RMap
containsKey, containsValue, entrySet, entrySet, entrySet, entrySet, fastPut, fastPutIfAbsent, fastPutIfExists, fastRemove, fastReplace, get, getAll, getCountDownLatch, getFairLock, getLock, getPermitExpirableSemaphore, getReadWriteLock, getSemaphore, keySet, keySet, keySet, keySet, loadAll, loadAll, mapReduce, put, putAll, putAll, putIfAbsent, putIfExists, randomEntries, randomKeys, readAllEntrySet, readAllKeySet, readAllMap, readAllValues, remove, remove, replace, replace, values, values, values, values, valueSize
-
Methods inherited from interface org.redisson.api.RMapAsync
addAndGetAsync, computeAsync, computeIfAbsentAsync, computeIfPresentAsync, fastPutAsync, fastPutIfAbsentAsync, fastPutIfExistsAsync, fastRemoveAsync, fastReplaceAsync, getAllAsync, getAsync, loadAllAsync, loadAllAsync, mergeAsync, putAllAsync, putAllAsync, putAsync, putIfAbsentAsync, putIfExistsAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, valueSizeAsync
-
Methods inherited from interface org.redisson.api.RMapCacheAsync
sizeAsync
-
Methods inherited from interface org.redisson.api.RObject
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
-
Methods inherited from interface org.redisson.api.RObjectAsync
addListenerAsync, copyAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, touchAsync, unlinkAsync
-
-
-
-
Constructor Detail
-
RedissonMapCache
public RedissonMapCache(EvictionScheduler evictionScheduler, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options, WriteBehindService writeBehindService)
-
RedissonMapCache
public RedissonMapCache(Codec codec, EvictionScheduler evictionScheduler, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options, WriteBehindService writeBehindService)
-
-
Method Detail
-
trySetMaxSize
public boolean trySetMaxSize(int maxSize)
Description copied from interface:RMapCache
Tries to set max size of the map. Superfluous elements are evicted using LRU algorithm.- Specified by:
trySetMaxSize
in interfaceRMapCache<K,V>
- Parameters:
maxSize
- - max size- Returns:
true
if max size has been successfully set, otherwisefalse
. If0
the cache is unbounded (default).
-
trySetMaxSize
public boolean trySetMaxSize(int maxSize, EvictionMode mode)
Description copied from interface:RMapCache
Tries to set max size of the map. Superfluous elements are evicted using defined algorithm.- Specified by:
trySetMaxSize
in interfaceRMapCache<K,V>
- Parameters:
maxSize
- - max sizemode
- - eviction mode- Returns:
true
if max size has been successfully set, otherwisefalse
.
-
trySetMaxSizeAsync
public RFuture<Boolean> trySetMaxSizeAsync(int maxSize)
Description copied from interface:RMapCacheAsync
Tries to set max size of the map. Superfluous elements are evicted using LRU algorithm by default.- Specified by:
trySetMaxSizeAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
maxSize
- - max size- Returns:
true
if max size has been successfully set, otherwisefalse
.
-
trySetMaxSizeAsync
public RFuture<Boolean> trySetMaxSizeAsync(int maxSize, EvictionMode mode)
Description copied from interface:RMapCacheAsync
Tries to set max size of the map. Superfluous elements are evicted using defined algorithm.- Specified by:
trySetMaxSizeAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
maxSize
- - max sizemode
- - eviction mode- Returns:
true
if max size has been successfully set, otherwisefalse
.
-
setMaxSize
public void setMaxSize(int maxSize)
Description copied from interface:RMapCache
Sets max size of the map and overrides current value. Superfluous elements are evicted using LRU algorithm.- Specified by:
setMaxSize
in interfaceRMapCache<K,V>
- Parameters:
maxSize
- - max size If0
the cache is unbounded (default).
-
setMaxSize
public void setMaxSize(int maxSize, EvictionMode mode)
Description copied from interface:RMapCache
Sets max size of the map and overrides current value. Superfluous elements are evicted using defined algorithm.- Specified by:
setMaxSize
in interfaceRMapCache<K,V>
- Parameters:
maxSize
- - max sizemode
- - eviction mode
-
setMaxSizeAsync
public RFuture<Void> setMaxSizeAsync(int maxSize)
Description copied from interface:RMapCacheAsync
Sets max size of the map and overrides current value. Superfluous elements are evicted using LRU algorithm by default.- Specified by:
setMaxSizeAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
maxSize
- - max size- Returns:
- void
-
setMaxSizeAsync
public RFuture<Void> setMaxSizeAsync(int maxSize, EvictionMode mode)
Description copied from interface:RMapCacheAsync
Sets max size of the map and overrides current value. Superfluous elements are evicted using defined algorithm.- Specified by:
setMaxSizeAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
maxSize
- - max sizemode
- - eviction mode- Returns:
- void
-
containsKeyAsync
public RFuture<Boolean> containsKeyAsync(Object key)
Description copied from interface:RMapAsync
Returnstrue
if this map contains map entry mapped by specifiedkey
, otherwisefalse
- Specified by:
containsKeyAsync
in interfaceRMapAsync<K,V>
- Overrides:
containsKeyAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map key- Returns:
true
if this map contains map entry mapped by specifiedkey
, otherwisefalse
-
containsValueAsync
public RFuture<Boolean> containsValueAsync(Object value)
Description copied from interface:RMapAsync
Returnstrue
if this map contains any map entry with specifiedvalue
, otherwisefalse
- Specified by:
containsValueAsync
in interfaceRMapAsync<K,V>
- Overrides:
containsValueAsync
in classRedissonMap<K,V>
- Parameters:
value
- - map value- Returns:
true
if this map contains any map entry with specifiedvalue
, otherwisefalse
-
getAllOperationAsync
public RFuture<Map<K,V>> getAllOperationAsync(Set<K> keys)
- Overrides:
getAllOperationAsync
in classRedissonMap<K,V>
-
putIfAbsent
public V putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCache
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.
- Specified by:
putIfAbsent
in interfaceRMapCache<K,V>
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.ttlUnit
- - time unit- Returns:
- current associated value
-
putIfAbsentAsync
public RFuture<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCacheAsync
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.
- Specified by:
putIfAbsentAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.ttlUnit
- - time unit- Returns:
- previous associated value
-
putIfAbsent
public V putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCache
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.
- Specified by:
putIfAbsent
in interfaceRMapCache<K,V>
- 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:
- current associated value
-
putIfAbsentAsync
public RFuture<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCacheAsync
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.
- Specified by:
putIfAbsentAsync
in interfaceRMapCacheAsync<K,V>
- 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
-
removeOperationAsync
protected RFuture<Boolean> removeOperationAsync(Object key, Object value)
- Overrides:
removeOperationAsync
in classRedissonMap<K,V>
-
getOperationAsync
public RFuture<V> getOperationAsync(K key)
- Overrides:
getOperationAsync
in classRedissonMap<K,V>
-
put
public V put(K key, V value, long ttl, TimeUnit unit)
Description copied from interface:RMapCache
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.
-
putOperationAsync
protected RFuture<V> putOperationAsync(K key, V value)
- Overrides:
putOperationAsync
in classRedissonMap<K,V>
-
putIfExistsOperationAsync
protected RFuture<V> putIfExistsOperationAsync(K key, V value)
- Overrides:
putIfExistsOperationAsync
in classRedissonMap<K,V>
-
putIfAbsentOperationAsync
protected RFuture<V> putIfAbsentOperationAsync(K key, V value)
- Overrides:
putIfAbsentOperationAsync
in classRedissonMap<K,V>
-
putAll
public void putAll(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCache
Associates the specifiedvalue
with the specifiedkey
in batch.If
MapWriter
is defined then new map entries will be stored in write-through mode.
-
putAllAsync
public RFuture<Void> putAllAsync(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCacheAsync
Associates the specifiedvalue
with the specifiedkey
in batch.If
MapWriter
is defined then new map entries are stored in write-through mode.- Specified by:
putAllAsync
in interfaceRMapCacheAsync<K,V>
- 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
-
addAndGet
public V addAndGet(K key, Number value)
Description copied from interface:RMap
Adds the givendelta
to the current value by mappedkey
. Works only for numeric values!
-
addAndGetOperationAsync
protected RFuture<V> addAndGetOperationAsync(K key, Number value)
- Overrides:
addAndGetOperationAsync
in classRedissonMap<K,V>
-
fastPut
public boolean fastPut(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCache
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
RMapCache.put(Object, Object, long, TimeUnit)
as it not returns previous value.- Specified by:
fastPut
in interfaceRMapCache<K,V>
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.ttlUnit
- - 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
public RFuture<Boolean> fastPutAsync(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCacheAsync
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
RMapCacheAsync.putAsync(Object, Object, long, TimeUnit)
as it not returns previous value.- Specified by:
fastPutAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.ttlUnit
- - 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.
-
fastPut
public boolean fastPut(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCache
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
RMapCache.put(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.- Specified by:
fastPut
in interfaceRMapCache<K,V>
- 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.
-
fastPutAsync
public RFuture<Boolean> fastPutAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCacheAsync
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
RMapCacheAsync.putAsync(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.- Specified by:
fastPutAsync
in interfaceRMapCacheAsync<K,V>
- 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.
-
fastPutOperationAsync
protected RFuture<Boolean> fastPutOperationAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
-
updateEntryExpiration
public boolean updateEntryExpiration(K key, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCache
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
.- Specified by:
updateEntryExpiration
in interfaceRMapCache<K,V>
- 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
.
-
updateEntryExpirationAsync
public RFuture<Boolean> updateEntryExpirationAsync(K key, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCacheAsync
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
.- Specified by:
updateEntryExpirationAsync
in interfaceRMapCacheAsync<K,V>
- 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
.
-
putAsync
public RFuture<V> putAsync(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCacheAsync
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.- Specified by:
putAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.ttlUnit
- - time unit- Returns:
- previous associated value
-
put
public V put(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCache
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.
- Specified by:
put
in interfaceRMapCache<K,V>
- 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
public RFuture<V> putAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCacheAsync
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.
- Specified by:
putAsync
in interfaceRMapCacheAsync<K,V>
- 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
-
putOperationAsync
protected RFuture<V> putOperationAsync(K key, V value, long ttlTimeout, long maxIdleTimeout, long maxIdleDelta, long ttlTimeoutDelta)
-
getWithTTLOnly
public V getWithTTLOnly(K key)
Description copied from interface:RMapCache
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.
- Specified by:
getWithTTLOnly
in interfaceRMapCache<K,V>
- Parameters:
key
- the key- Returns:
- the value mapped by defined
key
ornull
if value is absent
-
getWithTTLOnlyAsync
public RFuture<V> getWithTTLOnlyAsync(K key)
Description copied from interface:RMapCacheAsync
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.
- Specified by:
getWithTTLOnlyAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
key
- the key- Returns:
- the value mapped by defined
key
ornull
if value is absent
-
remainTimeToLive
public long remainTimeToLive(K key)
Description copied from interface:RMapCache
Remaining time to live of map entry associated with akey
.- Specified by:
remainTimeToLive
in interfaceRMapCache<K,V>
- Parameters:
key
- - map key- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
remainTimeToLiveAsync
public RFuture<Long> remainTimeToLiveAsync(K key)
Description copied from interface:RMapCacheAsync
Remaining time to live of map entry associated with akey
.- Specified by:
remainTimeToLiveAsync
in interfaceRMapCacheAsync<K,V>
- Parameters:
key
- - map key- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
removeOperationAsync
protected RFuture<V> removeOperationAsync(K key)
- Overrides:
removeOperationAsync
in classRedissonMap<K,V>
-
fastRemoveOperationBatchAsync
protected RFuture<List<Long>> fastRemoveOperationBatchAsync(K... keys)
- Overrides:
fastRemoveOperationBatchAsync
in classRedissonMap<K,V>
-
fastRemoveOperationAsync
protected RFuture<Long> fastRemoveOperationAsync(K... keys)
- Overrides:
fastRemoveOperationAsync
in classRedissonMap<K,V>
-
scanIterator
public ScanResult<Map.Entry<Object,Object>> scanIterator(String name, RedisClient client, long startPos, String pattern, int count)
- Overrides:
scanIterator
in classRedissonMap<K,V>
-
scanIteratorAsync
public RFuture<ScanResult<Map.Entry<Object,Object>>> scanIteratorAsync(String name, RedisClient client, long startPos, String pattern, int count)
- Overrides:
scanIteratorAsync
in classRedissonMap<K,V>
-
fastPutOperationAsync
protected RFuture<Boolean> fastPutOperationAsync(K key, V value)
- Overrides:
fastPutOperationAsync
in classRedissonMap<K,V>
-
fastPutIfExistsOperationAsync
protected RFuture<Boolean> fastPutIfExistsOperationAsync(K key, V value)
- Overrides:
fastPutIfExistsOperationAsync
in classRedissonMap<K,V>
-
fastPutIfAbsentOperationAsync
protected RFuture<Boolean> fastPutIfAbsentOperationAsync(K key, V value)
- Overrides:
fastPutIfAbsentOperationAsync
in classRedissonMap<K,V>
-
fastPutIfAbsent
public boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCache
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.
Works faster than usual
RMapCache.putIfAbsent(Object, Object, long, TimeUnit)
as it not returns previous value.- Specified by:
fastPutIfAbsent
in interfaceRMapCache<K,V>
- Parameters:
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry. If0
then stores infinitely.ttlUnit
- - 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
-
fastPutIfAbsent
public boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCache
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
RMapCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.- Specified by:
fastPutIfAbsent
in interfaceRMapCache<K,V>
- 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.
-
fastPutIfAbsentAsync
public RFuture<Boolean> fastPutIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
Description copied from interface:RMapCacheAsync
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
RMapCacheAsync.putIfAbsentAsync(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.- Specified by:
fastPutIfAbsentAsync
in interfaceRMapCacheAsync<K,V>
- 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
-
replaceOperationAsync
protected RFuture<Boolean> replaceOperationAsync(K key, V oldValue, V newValue)
- Overrides:
replaceOperationAsync
in classRedissonMap<K,V>
-
fastReplaceOperationAsync
protected RFuture<Boolean> fastReplaceOperationAsync(K key, V value)
- Overrides:
fastReplaceOperationAsync
in classRedissonMap<K,V>
-
replaceOperationAsync
protected RFuture<V> replaceOperationAsync(K key, V value)
- Overrides:
replaceOperationAsync
in classRedissonMap<K,V>
-
putAllOperationAsync
protected RFuture<Void> putAllOperationAsync(Map<? extends K,? extends V> map)
- Overrides:
putAllOperationAsync
in classRedissonMap<K,V>
-
addListener
public int addListener(MapEntryListener listener)
Description copied from interface:RMapCache
Adds map entry listener- Specified by:
addListener
in interfaceRMapCache<K,V>
- Parameters:
listener
- - entry listener- Returns:
- listener id
- See Also:
EntryCreatedListener
,EntryUpdatedListener
,EntryRemovedListener
,EntryExpiredListener
-
removeListener
public void removeListener(int listenerId)
Description copied from interface:RObject
Removes object event listener- Specified by:
removeListener
in interfaceRMapCache<K,V>
- Specified by:
removeListener
in interfaceRObject
- Overrides:
removeListener
in classRedissonObject
- Parameters:
listenerId
- - listener id
-
sizeInMemoryAsync
public RFuture<Long> sizeInMemoryAsync()
Description copied from interface:RObjectAsync
Returns bytes amount used by object in Redis memory.- Specified by:
sizeInMemoryAsync
in interfaceRObjectAsync
- Overrides:
sizeInMemoryAsync
in classRedissonObject
- Returns:
- size in bytes
-
clear
public void clear()
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsync
Delete object in async mode- Specified by:
deleteAsync
in interfaceRObjectAsync
- Overrides:
deleteAsync
in classRedissonObject
- Returns:
true
if object was deletedfalse
if not
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsync
Set a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
clearExpireAsync
public RFuture<Boolean> clearExpireAsync()
Description copied from interface:RExpirableAsync
Clear an expire timeout or expire date for object in async mode. Object will not be deleted.- Specified by:
clearExpireAsync
in interfaceRExpirableAsync
- Returns:
true
if the timeout was cleared andfalse
if not
-
readAllKeySetAsync
public RFuture<Set<K>> readAllKeySetAsync()
Description copied from interface:RMapAsync
Read all keys at once- Specified by:
readAllKeySetAsync
in interfaceRMapAsync<K,V>
- Overrides:
readAllKeySetAsync
in classRedissonMap<K,V>
- Returns:
- keys
-
randomKeysAsync
public RFuture<Set<K>> randomKeysAsync(int count)
Description copied from interface:RMapAsync
Returns random keys from this map limited bycount
- Specified by:
randomKeysAsync
in interfaceRMapAsync<K,V>
- Overrides:
randomKeysAsync
in classRedissonMap<K,V>
- Parameters:
count
- - keys amount to return- Returns:
- random keys
-
randomEntriesAsync
public RFuture<Map<K,V>> randomEntriesAsync(int count)
Description copied from interface:RMapAsync
Returns random map entries from this map limited bycount
- Specified by:
randomEntriesAsync
in interfaceRMapAsync<K,V>
- Overrides:
randomEntriesAsync
in classRedissonMap<K,V>
- Parameters:
count
- - entries amount to return- Returns:
- random entries
-
readAllEntrySetAsync
public RFuture<Set<Map.Entry<K,V>>> readAllEntrySetAsync()
Description copied from interface:RMapAsync
Read all map entries at once- Specified by:
readAllEntrySetAsync
in interfaceRMapAsync<K,V>
- Overrides:
readAllEntrySetAsync
in classRedissonMap<K,V>
- Returns:
- entries
-
readAllMapAsync
public RFuture<Map<K,V>> readAllMapAsync()
Description copied from interface:RMapAsync
Read all map as local instance at once- Specified by:
readAllMapAsync
in interfaceRMapAsync<K,V>
- Overrides:
readAllMapAsync
in classRedissonMap<K,V>
- Returns:
- map
-
readAllValuesAsync
public RFuture<Collection<V>> readAllValuesAsync()
Description copied from interface:RMapAsync
Read all values at once- Specified by:
readAllValuesAsync
in interfaceRMapAsync<K,V>
- Overrides:
readAllValuesAsync
in classRedissonMap<K,V>
- Returns:
- values
-
destroy
public void destroy()
Description copied from interface:RDestroyable
Destroys object when it's not necessary anymore.- Specified by:
destroy
in interfaceRDestroyable
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirable
Set a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unit- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(long timestamp)
Description copied from interface:RExpirableAsync
UseRExpirableAsync.expireAsync(Instant)
instead- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date in milliseconds (Unix timestamp)- Returns:
true
if the timeout was set andfalse
if not
-
expire
public boolean expire(Instant instant)
Description copied from interface:RExpirable
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expire
in interfaceRExpirable
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAsync
public RFuture<Boolean> expireAsync(Instant instant)
Description copied from interface:RExpirableAsync
Set an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAsync
in interfaceRExpirableAsync
- Parameters:
instant
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirable
UseRExpirable.expire(Instant)
instead- Specified by:
expireAt
in interfaceRExpirable
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(Date timestamp)
Description copied from interface:RExpirableAsync
UseRExpirableAsync.expireAsync(Instant)
instead- Specified by:
expireAtAsync
in interfaceRExpirableAsync
- Parameters:
timestamp
- - expire date- Returns:
true
if the timeout was set andfalse
if not
-
clearExpire
public boolean clearExpire()
Description copied from interface:RExpirable
Clear an expire timeout or expire date for object.- Specified by:
clearExpire
in interfaceRExpirable
- Returns:
true
if timeout was removedfalse
if object does not exist or does not have an associated timeout
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirable
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLive
in interfaceRExpirable
- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
remainTimeToLiveAsync
public RFuture<Long> remainTimeToLiveAsync()
Description copied from interface:RExpirableAsync
Remaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsync
in interfaceRExpirableAsync
- Returns:
- time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
-
expireAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
-
-