Class RedissonLocalCachedMap<K,V>
- java.lang.Object
-
- org.redisson.RedissonObject
-
- org.redisson.RedissonMap<K,V>
-
- org.redisson.RedissonLocalCachedMap<K,V>
-
- All Implemented Interfaces:
ConcurrentMap<K,V>
,Map<K,V>
,RDestroyable
,RExpirable
,RExpirableAsync
,RLocalCachedMap<K,V>
,RMap<K,V>
,RMapAsync<K,V>
,RObject
,RObjectAsync
public class RedissonLocalCachedMap<K,V> extends RedissonMap<K,V> implements RLocalCachedMap<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description static String
DISABLED_ACK_SUFFIX
static String
DISABLED_KEYS_SUFFIX
static String
TOPIC_SUFFIX
-
Fields inherited from class org.redisson.RedissonObject
codec, commandExecutor, name
-
-
Constructor Summary
Constructors Constructor Description RedissonLocalCachedMap(Codec codec, CommandAsyncExecutor connectionManager, String name, LocalCachedMapOptions<K,V> options, EvictionScheduler evictionScheduler, RedissonClient redisson, WriteBehindService writeBehindService)
RedissonLocalCachedMap(CommandAsyncExecutor commandExecutor, String name, LocalCachedMapOptions<K,V> options, EvictionScheduler evictionScheduler, RedissonClient redisson, WriteBehindService writeBehindService)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RFuture<V>
addAndGetOperationAsync(K key, Number value)
Set<Map.Entry<K,V>>
cachedEntrySet()
Returns all map entries stored in local cacheSet<K>
cachedKeySet()
Returns all keys stored in local cacheCollection<V>
cachedValues()
Returns all values stored in local cacheboolean
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)
void
clearLocalCache()
Clears local cache across all instancesRFuture<Void>
clearLocalCacheAsync()
Clears local cache across all instancesRFuture<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
protected io.netty.buffer.ByteBuf
createSyncMessage(io.netty.buffer.ByteBuf mapKey, io.netty.buffer.ByteBuf mapValue, CacheKey cacheKey)
RFuture<Boolean>
deleteAsync()
Delete object in async modevoid
destroy()
Destroys object when it's not necessary anymore.io.netty.buffer.ByteBuf
encode(Object value)
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)
insteadRFuture<Boolean>
fastPutIfAbsentAsync(K key, V value)
Stores the specifiedvalue
mapped by specifiedkey
only if there is no value with specifiedkey
stored before.RFuture<Boolean>
fastPutIfExistsAsync(K key, V value)
Stores the specifiedvalue
mapped bykey
only if mapping already exists.protected RFuture<Boolean>
fastPutOperationAsync(K key, V value)
protected RFuture<Long>
fastRemoveOperationAsync(K... keys)
protected RFuture<List<Long>>
fastRemoveOperationBatchAsync(K... keys)
RFuture<Boolean>
fastReplaceAsync(K key, V value)
Replaces previous value with a newvalue
mapped by specifiedkey
.protected RFuture<Boolean>
fastReplaceOperationAsync(K key, V value)
protected static byte[]
generateLogEntryId(byte[] keyHash)
RFuture<Map<K,V>>
getAllAsync(Set<K> keys)
Returns map slice contained the mappings with definedkeys
.RFuture<V>
getAsync(Object key)
Returns the value mapped by definedkey
ornull
if value is absent.Map<K,V>
getCachedMap()
Returns state of local cacheLocalCacheView<K,V>
getLocalCacheView()
void
preloadCache()
Pre-warm the cached entries.void
preloadCache(int count)
Pre-warm the cached entries.protected RFuture<Void>
putAllOperationAsync(Map<? extends K,? extends V> map)
RFuture<V>
putIfAbsentAsync(K key, V value)
Stores the specifiedvalue
mapped by specifiedkey
only if there is no value with specifiedkey
stored before.RFuture<V>
putIfExistsAsync(K key, V value)
Stores the specifiedvalue
mapped bykey
only if mapping already exists.protected RFuture<V>
putOperationAsync(K key, V value)
RFuture<Set<Map.Entry<K,V>>>
readAllEntrySetAsync()
Read all map entries 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 timeoutRFuture<Long>
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeoutRFuture<Boolean>
removeAsync(Object key, Object value)
Removes map entry only if it exists with specifiedkey
andvalue
.protected RFuture<Boolean>
removeOperationAsync(Object key, Object value)
protected RFuture<V>
removeOperationAsync(K key)
RFuture<V>
replaceAsync(K key, V value)
Replaces previous value with a newvalue
mapped by specifiedkey
.RFuture<Boolean>
replaceAsync(K key, V oldValue, V newValue)
Replaces previousoldValue
with anewValue
mapped by specifiedkey
.protected RFuture<V>
replaceOperationAsync(K key, V value)
protected RFuture<Boolean>
replaceOperationAsync(K key, V oldValue, V newValue)
RFuture<Integer>
sizeAsync()
Returns size of this mapRFuture<Long>
sizeInMemoryAsync()
Returns bytes amount used by object in Redis memory.-
Methods inherited from class org.redisson.RedissonMap
addAndGet, addAndGetAsync, checkKey, checkValue, clear, compute, computeAsync, computeIfAbsent, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, containsKey, containsKeyAsync, containsValue, entryIterator, entrySet, entrySet, entrySet, entrySet, equals, fastPut, fastPutAsync, fastPutIfAbsent, fastPutIfAbsentOperationAsync, fastPutIfExists, fastPutIfExistsOperationAsync, fastRemove, fastRemoveAsync, fastReplace, get, getAll, getAllOperationAsync, getCountDownLatch, getFairLock, getLock, getOperationAsync, 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, putIfAbsentOperationAsync, putIfExists, putIfExistsOperationAsync, randomEntries, randomEntriesAsync, randomKeys, randomKeysAsync, readAllEntrySet, readAllKeySet, readAllKeySetAsync, readAllMap, readAllValues, remove, remove, removeAsync, replace, replace, scanIterator, scanIteratorAsync, size, 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, encodeMapKey, encodeMapKeys, encodeMapValue, encodeMapValues, get, getCodec, getIdleTime, getIdleTimeAsync, getLockByMapKey, getLockByValue, getName, getRawName, getRawName, isExists, isExistsAsync, migrate, migrateAsync, move, moveAsync, prefixName, removeListener, 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
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
-
Methods inherited from interface org.redisson.api.RMap
addAndGet, 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, fastRemoveAsync, loadAllAsync, loadAllAsync, mergeAsync, putAllAsync, putAllAsync, putAsync, randomEntriesAsync, randomKeysAsync, readAllKeySetAsync, removeAsync, valueSizeAsync
-
Methods inherited from interface org.redisson.api.RObject
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, 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
-
-
-
-
Field Detail
-
TOPIC_SUFFIX
public static final String TOPIC_SUFFIX
- See Also:
- Constant Field Values
-
DISABLED_KEYS_SUFFIX
public static final String DISABLED_KEYS_SUFFIX
- See Also:
- Constant Field Values
-
DISABLED_ACK_SUFFIX
public static final String DISABLED_ACK_SUFFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RedissonLocalCachedMap
public RedissonLocalCachedMap(CommandAsyncExecutor commandExecutor, String name, LocalCachedMapOptions<K,V> options, EvictionScheduler evictionScheduler, RedissonClient redisson, WriteBehindService writeBehindService)
-
RedissonLocalCachedMap
public RedissonLocalCachedMap(Codec codec, CommandAsyncExecutor connectionManager, String name, LocalCachedMapOptions<K,V> options, EvictionScheduler evictionScheduler, RedissonClient redisson, WriteBehindService writeBehindService)
-
-
Method Detail
-
getLocalCacheView
public LocalCacheView<K,V> getLocalCacheView()
-
sizeAsync
public RFuture<Integer> sizeAsync()
Description copied from interface:RMapAsync
Returns size of this map
-
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
-
getAsync
public RFuture<V> getAsync(Object key)
Description copied from interface:RMapAsync
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.
-
generateLogEntryId
protected static byte[] generateLogEntryId(byte[] keyHash)
-
putOperationAsync
protected RFuture<V> putOperationAsync(K key, V value)
- Overrides:
putOperationAsync
in classRedissonMap<K,V>
-
createSyncMessage
protected io.netty.buffer.ByteBuf createSyncMessage(io.netty.buffer.ByteBuf mapKey, io.netty.buffer.ByteBuf mapValue, CacheKey cacheKey)
-
fastPutOperationAsync
protected RFuture<Boolean> fastPutOperationAsync(K key, V value)
- Overrides:
fastPutOperationAsync
in classRedissonMap<K,V>
-
destroy
public void destroy()
Description copied from interface:RDestroyable
Destroys object when it's not necessary anymore.- Specified by:
destroy
in interfaceRDestroyable
-
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>
-
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
-
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
-
getAllAsync
public RFuture<Map<K,V>> getAllAsync(Set<K> keys)
Description copied from interface:RMapAsync
Returns map slice contained the mappings with definedkeys
.If map doesn't contain value/values for specified key/keys and
MapLoader
is defined then value/values will be loaded in read-through mode.The returned map is NOT backed by the original map.
- Specified by:
getAllAsync
in interfaceRMapAsync<K,V>
- Overrides:
getAllAsync
in classRedissonMap<K,V>
- Parameters:
keys
- - map keys- Returns:
- Map slice
-
putAllOperationAsync
protected RFuture<Void> putAllOperationAsync(Map<? extends K,? extends V> map)
- Overrides:
putAllOperationAsync
in classRedissonMap<K,V>
-
addAndGetOperationAsync
protected RFuture<V> addAndGetOperationAsync(K key, Number value)
- Overrides:
addAndGetOperationAsync
in classRedissonMap<K,V>
-
fastPutIfAbsentAsync
public RFuture<Boolean> fastPutIfAbsentAsync(K key, V value)
Description copied from interface:RMapAsync
Stores the specifiedvalue
mapped by specifiedkey
only if there is no value with specifiedkey
stored before.Returns
true
if key is a new one in the hash and value was set orfalse
if key already exists in the hash and change hasn't been made.Works faster than
but not returning the previous value associated withRMapAsync.putIfAbsentAsync(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
fastPutIfAbsentAsync
in interfaceRMapAsync<K,V>
- Overrides:
fastPutIfAbsentAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key is a new one in the hash and value was set.false
if key already exists in the hash and change hasn't been made.
-
fastPutIfExistsAsync
public RFuture<Boolean> fastPutIfExistsAsync(K key, V value)
Description copied from interface:RMapAsync
Stores the specifiedvalue
mapped bykey
only if mapping already exists.Returns
true
if key is a new one in the hash and value was set orfalse
if key already exists in the hash and change hasn't been made.Works faster than
but doesn't return previous value associated withRMapAsync.putIfExistsAsync(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
fastPutIfExistsAsync
in interfaceRMapAsync<K,V>
- Overrides:
fastPutIfExistsAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key already exists in the hash and new value has been stored.false
if key doesn't exist in the hash and value hasn't been set.
-
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
-
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
-
preloadCache
public void preloadCache()
Description copied from interface:RLocalCachedMap
Pre-warm the cached entries. Not guaranteed to load ALL values, but statistically will preload approximately all (all if no concurrent mutating activity). Entries are loaded in a batch with size of 10 elements.- Specified by:
preloadCache
in interfaceRLocalCachedMap<K,V>
-
preloadCache
public void preloadCache(int count)
Description copied from interface:RLocalCachedMap
Pre-warm the cached entries. Not guaranteed to load ALL values, but statistically will preload approximately all (all if no concurrent mutating activity) Entries are loaded in a batch. Batch size is defined bycount
param.- Specified by:
preloadCache
in interfaceRLocalCachedMap<K,V>
- Parameters:
count
- - size of batch
-
clearLocalCache
public void clearLocalCache()
Description copied from interface:RLocalCachedMap
Clears local cache across all instances- Specified by:
clearLocalCache
in interfaceRLocalCachedMap<K,V>
-
clearLocalCacheAsync
public RFuture<Void> clearLocalCacheAsync()
Description copied from interface:RLocalCachedMap
Clears local cache across all instances- Specified by:
clearLocalCacheAsync
in interfaceRLocalCachedMap<K,V>
- Returns:
- void
-
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
-
fastReplaceAsync
public RFuture<Boolean> fastReplaceAsync(K key, V value)
Description copied from interface:RMapAsync
Replaces previous value with a newvalue
mapped by specifiedkey
.Works faster than
but not returning the previous value.RMapAsync.replaceAsync(Object, Object)
Returns
true
if key exists and value was updated orfalse
if key doesn't exists and value wasn't updated.If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
fastReplaceAsync
in interfaceRMapAsync<K,V>
- Overrides:
fastReplaceAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key exists and value was updated.false
if key doesn't exists and value wasn't updated.
-
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>
-
replaceAsync
public RFuture<V> replaceAsync(K key, V value)
Description copied from interface:RMapAsync
Replaces previous value with a newvalue
mapped by specifiedkey
. Returnsnull
if there is no map entry stored before and doesn't store new map entry.If
MapWriter
is defined then newvalue
is written in write-through mode.- Specified by:
replaceAsync
in interfaceRMapAsync<K,V>
- Overrides:
replaceAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
- previous associated value
or
null
if there is no map entry stored before and doesn't store new map entry
-
replaceOperationAsync
protected RFuture<Boolean> replaceOperationAsync(K key, V oldValue, V newValue)
- Overrides:
replaceOperationAsync
in classRedissonMap<K,V>
-
replaceAsync
public RFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
Description copied from interface:RMapAsync
Replaces previousoldValue
with anewValue
mapped by specifiedkey
. Returnsfalse
if previous value doesn't exist or equal tooldValue
.If
MapWriter
is defined thennewValue
is written in write-through mode.- Specified by:
replaceAsync
in interfaceRMapAsync<K,V>
- Overrides:
replaceAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map keyoldValue
- - map old valuenewValue
- - map new value- Returns:
true
if value has been replaced otherwisefalse
.
-
removeOperationAsync
protected RFuture<Boolean> removeOperationAsync(Object key, Object value)
- Overrides:
removeOperationAsync
in classRedissonMap<K,V>
-
removeAsync
public RFuture<Boolean> removeAsync(Object key, Object value)
Description copied from interface:RMapAsync
Removes map entry only if it exists with specifiedkey
andvalue
.If
MapWriter
is defined thenkey
is deleted in write-through mode.- Specified by:
removeAsync
in interfaceRMapAsync<K,V>
- Overrides:
removeAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if map entry has been removed otherwisefalse
.
-
putIfExistsAsync
public RFuture<V> putIfExistsAsync(K key, V value)
Description copied from interface:RMapAsync
Stores the specifiedvalue
mapped bykey
only if mapping already exists.If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
putIfExistsAsync
in interfaceRMapAsync<K,V>
- Overrides:
putIfExistsAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
null
if key is doesn't exists in the hash and value hasn't been set. Previous value if key already exists in the hash and new value has been stored.
-
putIfAbsentAsync
public RFuture<V> putIfAbsentAsync(K key, V value)
Description copied from interface:RMapAsync
Stores the specifiedvalue
mapped by specifiedkey
only if there is no value with specifiedkey
stored before.If
MapWriter
is defined then new map entry is stored in write-through mode.- Specified by:
putIfAbsentAsync
in interfaceRMapAsync<K,V>
- Overrides:
putIfAbsentAsync
in classRedissonMap<K,V>
- Parameters:
key
- - map keyvalue
- - map value- Returns:
null
if key is a new one in the hash and value was set. Previous value if key already exists in the hash and change hasn't been made.
-
encode
public io.netty.buffer.ByteBuf encode(Object value)
- Overrides:
encode
in classRedissonObject
-
cachedKeySet
public Set<K> cachedKeySet()
Description copied from interface:RLocalCachedMap
Returns all keys stored in local cache- Specified by:
cachedKeySet
in interfaceRLocalCachedMap<K,V>
- Returns:
- keys
-
cachedValues
public Collection<V> cachedValues()
Description copied from interface:RLocalCachedMap
Returns all values stored in local cache- Specified by:
cachedValues
in interfaceRLocalCachedMap<K,V>
- Returns:
- values
-
cachedEntrySet
public Set<Map.Entry<K,V>> cachedEntrySet()
Description copied from interface:RLocalCachedMap
Returns all map entries stored in local cache- Specified by:
cachedEntrySet
in interfaceRLocalCachedMap<K,V>
- Returns:
- entries
-
getCachedMap
public Map<K,V> getCachedMap()
Description copied from interface:RLocalCachedMap
Returns state of local cache- Specified by:
getCachedMap
in interfaceRLocalCachedMap<K,V>
- Returns:
- map
-
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
-
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
-
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
-
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
-
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)
-
-