Class RedissonMapCache<K,V>
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonMap<K,V>
-
- org.redisson.RedissonMapCache<K,V>
-
- Type Parameters:
K
- keyV
- value
- All Implemented Interfaces:
<K,V>
,<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, name, RedissonClient redisson, MapOptions<K,V> options, WriteBehindService writeBehindService)
RedissonMapCache(EvictionScheduler evictionScheduler, CommandAsyncExecutor commandExecutor, 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, value)
Adds the givendelta
to the current value by mappedkey
.protected RFuture<V>
addAndGetOperationAsync(K key, value)
int
addListener(MapEntryListener listener)
Adds map entry listenervoid
clear()
boolean
clearExpire()
Clear an expire timeout or expire date for object.>
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.protected >
... keys)
>
key)
Returnstrue
if this map contains map entry mapped by specifiedkey
, otherwisefalse
>
value)
Returnstrue
if this map contains any map entry with specifiedvalue
, otherwisefalse
>
deleteAsync()
Delete object in async modevoid
destroy()
Destroys object when it's not necessary anymore.boolean
expire(long timeToLive, timeUnit)
Set a timeout for object.boolean
instant)
Set an expire date for object.>
expireAsync(long timeToLive, timeUnit)
Set a timeout for object in async mode.protected >
expireAsync(long timeToLive, timeUnit, ... keys)
>
instant)
Set an expire date for object.boolean
expireAt(long timestamp)
UseRExpirable.expire(Instant)
insteadboolean
timestamp)
UseRExpirable.expire(Instant)
instead>
expireAtAsync(long timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadprotected >
expireAtAsync(long timestamp, ... keys)
>
timestamp)
UseRExpirableAsync.expireAsync(Instant)
insteadboolean
fastPut(K key, V value, long ttl, ttlUnit)
Stores value mapped by key with specified time to live.boolean
fastPut(K key, V value, long ttl, ttlUnit, long maxIdleTime, maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.>
fastPutAsync(K key, V value, long ttl, ttlUnit)
Stores value mapped by key with specified time to live.>
fastPutAsync(K key, V value, long ttl, ttlUnit, long maxIdleTime, maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.boolean
fastPutIfAbsent(K key, V value, long ttl, 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, ttlUnit, long maxIdleTime, maxIdleUnit)
If the specified key is not already associated with a value, associate it with the given value.>
fastPutIfAbsentAsync(K key, V value, long ttl, ttlUnit, long maxIdleTime, maxIdleUnit)
If the specified key is not already associated with a value, associate it with the given value.protected >
fastPutIfAbsentOperationAsync(K key, V value)
protected >
fastPutIfExistsOperationAsync(K key, V value)
protected >
fastPutOperationAsync(K key, V value)
protected >
fastPutOperationAsync(K key, V value, long ttl, ttlUnit, long maxIdleTime, maxIdleUnit)
protected >
fastRemoveOperationAsync(K... keys)
protected <>>
fastRemoveOperationBatchAsync(K... keys)
protected >
fastReplaceOperationAsync(K key, V value)
<K,V>>
<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, unit)
Stores value mapped by key with specified time to live.V
put(K key, V value, long ttl, ttlUnit, long maxIdleTime, maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.void
<? extends K,? extends V> map, long ttl, ttlUnit)
Associates the specifiedvalue
with the specifiedkey
in batch.>
<? extends K,? extends V> map, long ttl, ttlUnit)
Associates the specifiedvalue
with the specifiedkey
in batch.protected >
<? extends K,? extends V> map)
RFuture<V>
putAsync(K key, V value, long ttl, ttlUnit)
Stores value mapped by key with specified time to live.RFuture<V>
putAsync(K key, V value, long ttl, ttlUnit, long maxIdleTime, maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.V
putIfAbsent(K key, V value, long ttl, 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, ttlUnit, long maxIdleTime, 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, 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, ttlUnit, long maxIdleTime, 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)
<K,V>>
randomEntriesAsync(int count)
Returns random map entries from this map limited bycount
<K>>
randomKeysAsync(int count)
Returns random keys from this map limited bycount
<<K,V>>>
readAllEntrySetAsync()
Read all map entries at once<K>>
readAllKeySetAsync()
Read all keys at once<K,V>>
readAllMapAsync()
Read all map as local instance at once<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
.>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeout>
remainTimeToLiveAsync(K key)
Remaining time to live of map entry associated with akey
.void
removeListener(int listenerId)
Removes object event listenerprotected >
key, value)
protected RFuture<V>
removeOperationAsync(K key)
protected RFuture<V>
replaceOperationAsync(K key, V value)
protected >
replaceOperationAsync(K key, V oldValue, V newValue)
<,>>
name, RedisClient client, long startPos, pattern, int count)
<,>>>
name, RedisClient client, long startPos, 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.>
setMaxSizeAsync(int maxSize)
Sets max size of the map and overrides current value.>
setMaxSizeAsync(int maxSize, EvictionMode mode)
Sets max size of the map and overrides current value.>
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.>
trySetMaxSizeAsync(int maxSize)
Tries to set max size of the map.>
trySetMaxSizeAsync(int maxSize, EvictionMode mode)
Tries to set max size of the map.boolean
updateEntryExpiration(K key, long ttl, ttlUnit, long maxIdleTime, maxIdleUnit)
Updates time to live and max idle time of specified entry by key.>
updateEntryExpirationAsync(K key, long ttl, ttlUnit, long maxIdleTime, 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 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, name, RedissonClient redisson, MapOptions<K,V> options, WriteBehindService writeBehindService)
-
RedissonMapCache
public RedissonMapCache(Codec codec, EvictionScheduler evictionScheduler, CommandAsyncExecutor commandExecutor, 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 > 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 > 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 > 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 > 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 > containsKeyAsync( 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 > containsValueAsync( 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 <<K> keys)
- Overrides:
getAllOperationAsync
in classRedissonMap<K,V>
-
putIfAbsent
public V putIfAbsent(K key, V value, long ttl, 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, 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, ttlUnit, long maxIdleTime, 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, ttlUnit, long maxIdleTime, 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 > removeOperationAsync( key, 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, 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(<? extends K,? extends V> map, long ttl, 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 > putAllAsync(<? extends K,? extends V> map, long ttl, 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, 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, value)
- Overrides:
addAndGetOperationAsync
in classRedissonMap<K,V>
-
fastPut
public boolean fastPut(K key, V value, long ttl, 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 > fastPutAsync(K key, V value, long ttl, 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, ttlUnit, long maxIdleTime, 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 > fastPutAsync(K key, V value, long ttl, ttlUnit, long maxIdleTime, 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 > fastPutOperationAsync(K key, V value, long ttl, ttlUnit, long maxIdleTime, maxIdleUnit)
-
updateEntryExpiration
public boolean updateEntryExpiration(K key, long ttl, ttlUnit, long maxIdleTime, 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 > updateEntryExpirationAsync(K key, long ttl, ttlUnit, long maxIdleTime, 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, 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, ttlUnit, long maxIdleTime, 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, ttlUnit, long maxIdleTime, 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 > 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 <>> fastRemoveOperationBatchAsync(K... keys)
- Overrides:
fastRemoveOperationBatchAsync
in classRedissonMap<K,V>
-
fastRemoveOperationAsync
protected > fastRemoveOperationAsync(K... keys)
- Overrides:
fastRemoveOperationAsync
in classRedissonMap<K,V>
-
scanIterator
public <,>> scanIterator( name, RedisClient client, long startPos, pattern, int count)
- Overrides:
scanIterator
in classRedissonMap<K,V>
-
scanIteratorAsync
public <,>>> scanIteratorAsync( name, RedisClient client, long startPos, pattern, int count)
- Overrides:
scanIteratorAsync
in classRedissonMap<K,V>
-
fastPutOperationAsync
protected > fastPutOperationAsync(K key, V value)
- Overrides:
fastPutOperationAsync
in classRedissonMap<K,V>
-
fastPutIfExistsOperationAsync
protected > fastPutIfExistsOperationAsync(K key, V value)
- Overrides:
fastPutIfExistsOperationAsync
in classRedissonMap<K,V>
-
fastPutIfAbsentOperationAsync
protected > fastPutIfAbsentOperationAsync(K key, V value)
- Overrides:
fastPutIfAbsentOperationAsync
in classRedissonMap<K,V>
-
fastPutIfAbsent
public boolean fastPutIfAbsent(K key, V value, long ttl, 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, ttlUnit, long maxIdleTime, 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 > fastPutIfAbsentAsync(K key, V value, long ttl, ttlUnit, long maxIdleTime, 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 > replaceOperationAsync(K key, V oldValue, V newValue)
- Overrides:
replaceOperationAsync
in classRedissonMap<K,V>
-
fastReplaceOperationAsync
protected > 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 > putAllOperationAsync(<? 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 > 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 > 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 > expireAsync(long timeToLive, 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
-
expireAtAsync
protected > expireAtAsync(long timestamp, ... keys)
-
clearExpireAsync
public > 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 <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 <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 <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 <<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 <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 <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)
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 > 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)
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 > expireAsync( 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( 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 > expireAtAsync( 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 > 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 > expireAsync(long timeToLive, timeUnit, ... keys)
-
clearExpireAsync
protected > clearExpireAsync(... keys)
-
-