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
RedissonMapobject.- 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 VaddAndGet(K key, Number value)Adds the givendeltato the current value by mappedkey.protected RFuture<V>addAndGetOperationAsync(K key, Number value)intaddListener(MapEntryListener listener)Adds map entry listenervoidclear()booleanclearExpire()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)Returnstrueif this map contains map entry mapped by specifiedkey, otherwisefalseRFuture<Boolean>containsValueAsync(Object value)Returnstrueif this map contains any map entry with specifiedvalue, otherwisefalseRFuture<Boolean>deleteAsync()Delete object in async modevoiddestroy()Destroys object when it's not necessary anymore.booleanexpire(long timeToLive, TimeUnit timeUnit)Set a timeout for object.booleanexpire(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.booleanexpireAt(long timestamp)UseRExpirable.expire(Instant)insteadbooleanexpireAt(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)insteadbooleanfastPut(K key, V value, long ttl, TimeUnit ttlUnit)Stores value mapped by key with specified time to live.booleanfastPut(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.booleanfastPutIfAbsent(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.booleanfastPutIfAbsent(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)VgetWithTTLOnly(K key)Returns the value mapped by definedkeyornullif value is absent.RFuture<V>getWithTTLOnlyAsync(K key)Returns the value mapped by definedkeyornullif value is absent.Vput(K key, V value, long ttl, TimeUnit unit)Stores value mapped by key with specified time to live.Vput(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.voidputAll(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)Associates the specifiedvaluewith the specifiedkeyin batch.RFuture<Void>putAllAsync(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)Associates the specifiedvaluewith the specifiedkeyin 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.VputIfAbsent(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.VputIfAbsent(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 bycountRFuture<Set<K>>randomKeysAsync(int count)Returns random keys from this map limited bycountRFuture<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 oncelongremainTimeToLive()Remaining time to live of Redisson object that has a timeoutlongremainTimeToLive(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.voidremoveListener(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)voidsetMaxSize(int maxSize)Sets max size of the map and overrides current value.voidsetMaxSize(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.booleantrySetMaxSize(int maxSize)Tries to set max size of the map.booleantrySetMaxSize(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.booleanupdateEntryExpiration(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:RMapCacheTries to set max size of the map. Superfluous elements are evicted using LRU algorithm.- Specified by:
trySetMaxSizein interfaceRMapCache<K,V>- Parameters:
maxSize- - max size- Returns:
trueif max size has been successfully set, otherwisefalse. If0the cache is unbounded (default).
-
trySetMaxSize
public boolean trySetMaxSize(int maxSize, EvictionMode mode)Description copied from interface:RMapCacheTries to set max size of the map. Superfluous elements are evicted using defined algorithm.- Specified by:
trySetMaxSizein interfaceRMapCache<K,V>- Parameters:
maxSize- - max sizemode- - eviction mode- Returns:
trueif max size has been successfully set, otherwisefalse.
-
trySetMaxSizeAsync
public RFuture<Boolean> trySetMaxSizeAsync(int maxSize)
Description copied from interface:RMapCacheAsyncTries to set max size of the map. Superfluous elements are evicted using LRU algorithm by default.- Specified by:
trySetMaxSizeAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
maxSize- - max size- Returns:
trueif max size has been successfully set, otherwisefalse.
-
trySetMaxSizeAsync
public RFuture<Boolean> trySetMaxSizeAsync(int maxSize, EvictionMode mode)
Description copied from interface:RMapCacheAsyncTries to set max size of the map. Superfluous elements are evicted using defined algorithm.- Specified by:
trySetMaxSizeAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
maxSize- - max sizemode- - eviction mode- Returns:
trueif max size has been successfully set, otherwisefalse.
-
setMaxSize
public void setMaxSize(int maxSize)
Description copied from interface:RMapCacheSets max size of the map and overrides current value. Superfluous elements are evicted using LRU algorithm.- Specified by:
setMaxSizein interfaceRMapCache<K,V>- Parameters:
maxSize- - max size If0the cache is unbounded (default).
-
setMaxSize
public void setMaxSize(int maxSize, EvictionMode mode)Description copied from interface:RMapCacheSets max size of the map and overrides current value. Superfluous elements are evicted using defined algorithm.- Specified by:
setMaxSizein interfaceRMapCache<K,V>- Parameters:
maxSize- - max sizemode- - eviction mode
-
setMaxSizeAsync
public RFuture<Void> setMaxSizeAsync(int maxSize)
Description copied from interface:RMapCacheAsyncSets max size of the map and overrides current value. Superfluous elements are evicted using LRU algorithm by default.- Specified by:
setMaxSizeAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
maxSize- - max size- Returns:
- void
-
setMaxSizeAsync
public RFuture<Void> setMaxSizeAsync(int maxSize, EvictionMode mode)
Description copied from interface:RMapCacheAsyncSets max size of the map and overrides current value. Superfluous elements are evicted using defined algorithm.- Specified by:
setMaxSizeAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
maxSize- - max sizemode- - eviction mode- Returns:
- void
-
containsKeyAsync
public RFuture<Boolean> containsKeyAsync(Object key)
Description copied from interface:RMapAsyncReturnstrueif this map contains map entry mapped by specifiedkey, otherwisefalse- Specified by:
containsKeyAsyncin interfaceRMapAsync<K,V>- Overrides:
containsKeyAsyncin classRedissonMap<K,V>- Parameters:
key- - map key- Returns:
trueif this map contains map entry mapped by specifiedkey, otherwisefalse
-
containsValueAsync
public RFuture<Boolean> containsValueAsync(Object value)
Description copied from interface:RMapAsyncReturnstrueif this map contains any map entry with specifiedvalue, otherwisefalse- Specified by:
containsValueAsyncin interfaceRMapAsync<K,V>- Overrides:
containsValueAsyncin classRedissonMap<K,V>- Parameters:
value- - map value- Returns:
trueif this map contains any map entry with specifiedvalue, otherwisefalse
-
getAllOperationAsync
public RFuture<Map<K,V>> getAllOperationAsync(Set<K> keys)
- Overrides:
getAllOperationAsyncin classRedissonMap<K,V>
-
putIfAbsent
public V putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCacheIf 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:
putIfAbsentin interfaceRMapCache<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then 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:RMapCacheAsyncIf 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:
putIfAbsentAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then 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:RMapCacheIf 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:
putIfAbsentin interfaceRMapCache<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then 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:RMapCacheAsyncIf 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:
putIfAbsentAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then entry stores infinitely.- Returns:
- previous associated value
-
removeOperationAsync
protected RFuture<Boolean> removeOperationAsync(Object key, Object value)
- Overrides:
removeOperationAsyncin classRedissonMap<K,V>
-
getOperationAsync
public RFuture<V> getOperationAsync(K key)
- Overrides:
getOperationAsyncin classRedissonMap<K,V>
-
put
public V put(K key, V value, long ttl, TimeUnit unit)
Description copied from interface:RMapCacheStores 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:
putOperationAsyncin classRedissonMap<K,V>
-
putIfExistsOperationAsync
protected RFuture<V> putIfExistsOperationAsync(K key, V value)
- Overrides:
putIfExistsOperationAsyncin classRedissonMap<K,V>
-
putIfAbsentOperationAsync
protected RFuture<V> putIfAbsentOperationAsync(K key, V value)
- Overrides:
putIfAbsentOperationAsyncin classRedissonMap<K,V>
-
putAll
public void putAll(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCacheAssociates the specifiedvaluewith the specifiedkeyin batch.If
MapWriteris 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:RMapCacheAsyncAssociates the specifiedvaluewith the specifiedkeyin batch.If
MapWriteris defined then new map entries are stored in write-through mode.- Specified by:
putAllAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
map- - mappings to be stored in this mapttl- - time to live for all key\value entries. If0then stores infinitely.ttlUnit- - time unit- Returns:
- void
-
addAndGet
public V addAndGet(K key, Number value)
Description copied from interface:RMapAdds the givendeltato the current value by mappedkey. Works only for numeric values!
-
addAndGetOperationAsync
protected RFuture<V> addAndGetOperationAsync(K key, Number value)
- Overrides:
addAndGetOperationAsyncin classRedissonMap<K,V>
-
fastPut
public boolean fastPut(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCacheStores 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:
fastPutin interfaceRMapCache<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then stores infinitely.ttlUnit- - time unit- Returns:
trueif key is a new key in the hash and value was set.falseif 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:RMapCacheAsyncStores 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:
fastPutAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then stores infinitely.ttlUnit- - time unit- Returns:
trueif key is a new key in the hash and value was set.falseif 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:RMapCacheStores 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:
fastPutin interfaceRMapCache<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then entry stores infinitely.- Returns:
trueif key is a new key in the hash and value was set.falseif 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:RMapCacheAsyncStores 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:
fastPutAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then entry stores infinitely.- Returns:
trueif key is a new key in the hash and value was set.falseif 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:RMapCacheUpdates 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
falseif entry already expired or doesn't exist, otherwise returnstrue.- Specified by:
updateEntryExpirationin interfaceRMapCache<K,V>- Parameters:
key- - map keyttl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then entry stores infinitely.- Returns:
- returns
falseif 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:RMapCacheAsyncUpdates 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
falseif entry already expired or doesn't exist, otherwise returnstrue.- Specified by:
updateEntryExpirationAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- - map keyttl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then entry stores infinitely.- Returns:
- returns
falseif 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:RMapCacheAsyncStores 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:
putAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then 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:RMapCacheStores 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:
putin interfaceRMapCache<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then 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:RMapCacheAsyncStores 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:
putAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then 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:RMapCacheReturns the value mapped by definedkeyornullif value is absent.If map doesn't contain value for specified key and
MapLoaderis 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:
getWithTTLOnlyin interfaceRMapCache<K,V>- Parameters:
key- the key- Returns:
- the value mapped by defined
keyornullif value is absent
-
getWithTTLOnlyAsync
public RFuture<V> getWithTTLOnlyAsync(K key)
Description copied from interface:RMapCacheAsyncReturns the value mapped by definedkeyornullif value is absent.If map doesn't contain value for specified key and
MapLoaderis 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:
getWithTTLOnlyAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- the key- Returns:
- the value mapped by defined
keyornullif value is absent
-
remainTimeToLive
public long remainTimeToLive(K key)
Description copied from interface:RMapCacheRemaining time to live of map entry associated with akey.- Specified by:
remainTimeToLivein 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:RMapCacheAsyncRemaining time to live of map entry associated with akey.- Specified by:
remainTimeToLiveAsyncin 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:
removeOperationAsyncin classRedissonMap<K,V>
-
fastRemoveOperationBatchAsync
protected RFuture<List<Long>> fastRemoveOperationBatchAsync(K... keys)
- Overrides:
fastRemoveOperationBatchAsyncin classRedissonMap<K,V>
-
fastRemoveOperationAsync
protected RFuture<Long> fastRemoveOperationAsync(K... keys)
- Overrides:
fastRemoveOperationAsyncin classRedissonMap<K,V>
-
scanIterator
public ScanResult<Map.Entry<Object,Object>> scanIterator(String name, RedisClient client, long startPos, String pattern, int count)
- Overrides:
scanIteratorin classRedissonMap<K,V>
-
scanIteratorAsync
public RFuture<ScanResult<Map.Entry<Object,Object>>> scanIteratorAsync(String name, RedisClient client, long startPos, String pattern, int count)
- Overrides:
scanIteratorAsyncin classRedissonMap<K,V>
-
fastPutOperationAsync
protected RFuture<Boolean> fastPutOperationAsync(K key, V value)
- Overrides:
fastPutOperationAsyncin classRedissonMap<K,V>
-
fastPutIfExistsOperationAsync
protected RFuture<Boolean> fastPutIfExistsOperationAsync(K key, V value)
- Overrides:
fastPutIfExistsOperationAsyncin classRedissonMap<K,V>
-
fastPutIfAbsentOperationAsync
protected RFuture<Boolean> fastPutIfAbsentOperationAsync(K key, V value)
- Overrides:
fastPutIfAbsentOperationAsyncin classRedissonMap<K,V>
-
fastPutIfAbsent
public boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
Description copied from interface:RMapCacheIf 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:
fastPutIfAbsentin interfaceRMapCache<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then stores infinitely.ttlUnit- - time unit- Returns:
trueif key is a new key in the hash and value was set.falseif 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:RMapCacheIf 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:
fastPutIfAbsentin interfaceRMapCache<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then entry stores infinitely.- Returns:
trueif key is a new key in the hash and value was set.falseif 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:RMapCacheAsyncIf 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:
fastPutIfAbsentAsyncin interfaceRMapCacheAsync<K,V>- Parameters:
key- - map keyvalue- - map valuettl- - time to live for key\value entry. If0then time to live doesn't affect entry expiration.ttlUnit- - time unitmaxIdleTime- - max idle time for key\value entry. If0then max idle time doesn't affect entry expiration.maxIdleUnit- - time unitif
maxIdleTimeandttlparams are equal to0then entry stores infinitely.- Returns:
trueif key is a new key in the hash and value was set.falseif key already exists in the hash
-
replaceOperationAsync
protected RFuture<Boolean> replaceOperationAsync(K key, V oldValue, V newValue)
- Overrides:
replaceOperationAsyncin classRedissonMap<K,V>
-
fastReplaceOperationAsync
protected RFuture<Boolean> fastReplaceOperationAsync(K key, V value)
- Overrides:
fastReplaceOperationAsyncin classRedissonMap<K,V>
-
replaceOperationAsync
protected RFuture<V> replaceOperationAsync(K key, V value)
- Overrides:
replaceOperationAsyncin classRedissonMap<K,V>
-
putAllOperationAsync
protected RFuture<Void> putAllOperationAsync(Map<? extends K,? extends V> map)
- Overrides:
putAllOperationAsyncin classRedissonMap<K,V>
-
addListener
public int addListener(MapEntryListener listener)
Description copied from interface:RMapCacheAdds map entry listener- Specified by:
addListenerin 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:RObjectRemoves object event listener- Specified by:
removeListenerin interfaceRMapCache<K,V>- Specified by:
removeListenerin interfaceRObject- Overrides:
removeListenerin classRedissonObject- Parameters:
listenerId- - listener id
-
sizeInMemoryAsync
public RFuture<Long> sizeInMemoryAsync()
Description copied from interface:RObjectAsyncReturns bytes amount used by object in Redis memory.- Specified by:
sizeInMemoryAsyncin interfaceRObjectAsync- Overrides:
sizeInMemoryAsyncin classRedissonObject- Returns:
- size in bytes
-
clear
public void clear()
-
deleteAsync
public RFuture<Boolean> deleteAsync()
Description copied from interface:RObjectAsyncDelete object in async mode- Specified by:
deleteAsyncin interfaceRObjectAsync- Overrides:
deleteAsyncin classRedissonObject- Returns:
trueif object was deletedfalseif not
-
expireAsync
public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
Description copied from interface:RExpirableAsyncSet a timeout for object in async mode. After the timeout has expired, the key will automatically be deleted.- Specified by:
expireAsyncin interfaceRExpirableAsync- Parameters:
timeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
clearExpireAsync
public RFuture<Boolean> clearExpireAsync()
Description copied from interface:RExpirableAsyncClear an expire timeout or expire date for object in async mode. Object will not be deleted.- Specified by:
clearExpireAsyncin interfaceRExpirableAsync- Returns:
trueif the timeout was cleared andfalseif not
-
readAllKeySetAsync
public RFuture<Set<K>> readAllKeySetAsync()
Description copied from interface:RMapAsyncRead all keys at once- Specified by:
readAllKeySetAsyncin interfaceRMapAsync<K,V>- Overrides:
readAllKeySetAsyncin classRedissonMap<K,V>- Returns:
- keys
-
randomKeysAsync
public RFuture<Set<K>> randomKeysAsync(int count)
Description copied from interface:RMapAsyncReturns random keys from this map limited bycount- Specified by:
randomKeysAsyncin interfaceRMapAsync<K,V>- Overrides:
randomKeysAsyncin 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:RMapAsyncReturns random map entries from this map limited bycount- Specified by:
randomEntriesAsyncin interfaceRMapAsync<K,V>- Overrides:
randomEntriesAsyncin 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:RMapAsyncRead all map entries at once- Specified by:
readAllEntrySetAsyncin interfaceRMapAsync<K,V>- Overrides:
readAllEntrySetAsyncin classRedissonMap<K,V>- Returns:
- entries
-
readAllMapAsync
public RFuture<Map<K,V>> readAllMapAsync()
Description copied from interface:RMapAsyncRead all map as local instance at once- Specified by:
readAllMapAsyncin interfaceRMapAsync<K,V>- Overrides:
readAllMapAsyncin classRedissonMap<K,V>- Returns:
- map
-
readAllValuesAsync
public RFuture<Collection<V>> readAllValuesAsync()
Description copied from interface:RMapAsyncRead all values at once- Specified by:
readAllValuesAsyncin interfaceRMapAsync<K,V>- Overrides:
readAllValuesAsyncin classRedissonMap<K,V>- Returns:
- values
-
destroy
public void destroy()
Description copied from interface:RDestroyableDestroys object when it's not necessary anymore.- Specified by:
destroyin interfaceRDestroyable
-
expire
public boolean expire(long timeToLive, TimeUnit timeUnit)Description copied from interface:RExpirableSet a timeout for object. After the timeout has expired, the key will automatically be deleted.- Specified by:
expirein interfaceRExpirable- Parameters:
timeToLive- - timeout before object will be deletedtimeUnit- - timeout time unit- Returns:
trueif the timeout was set andfalseif not
-
expireAt
public boolean expireAt(long timestamp)
Description copied from interface:RExpirableUseRExpirable.expire(Instant)instead- Specified by:
expireAtin interfaceRExpirable- Parameters:
timestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(long timestamp)
Description copied from interface:RExpirableAsyncUseRExpirableAsync.expireAsync(Instant)instead- Specified by:
expireAtAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date in milliseconds (Unix timestamp)- Returns:
trueif the timeout was set andfalseif not
-
expire
public boolean expire(Instant instant)
Description copied from interface:RExpirableSet an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expirein interfaceRExpirable- Parameters:
instant- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAsync
public RFuture<Boolean> expireAsync(Instant instant)
Description copied from interface:RExpirableAsyncSet an expire date for object. When expire date comes the key will automatically be deleted.- Specified by:
expireAsyncin interfaceRExpirableAsync- Parameters:
instant- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAt
public boolean expireAt(Date timestamp)
Description copied from interface:RExpirableUseRExpirable.expire(Instant)instead- Specified by:
expireAtin interfaceRExpirable- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
expireAtAsync
public RFuture<Boolean> expireAtAsync(Date timestamp)
Description copied from interface:RExpirableAsyncUseRExpirableAsync.expireAsync(Instant)instead- Specified by:
expireAtAsyncin interfaceRExpirableAsync- Parameters:
timestamp- - expire date- Returns:
trueif the timeout was set andfalseif not
-
clearExpire
public boolean clearExpire()
Description copied from interface:RExpirableClear an expire timeout or expire date for object.- Specified by:
clearExpirein interfaceRExpirable- Returns:
trueif timeout was removedfalseif object does not exist or does not have an associated timeout
-
remainTimeToLive
public long remainTimeToLive()
Description copied from interface:RExpirableRemaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLivein 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:RExpirableAsyncRemaining time to live of Redisson object that has a timeout- Specified by:
remainTimeToLiveAsyncin 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)
-
-