K
- keyV
- valuepublic 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)
or putIfAbsent(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.
codec, commandExecutor, name
Constructor and 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) |
Modifier and Type | Method and Description |
---|---|
V |
addAndGet(K key,
Number value)
Adds the given
delta to the current value
by mapped key . |
protected RFuture<V> |
addAndGetOperationAsync(K key,
Number value) |
int |
addListener(MapEntryListener listener)
Adds map entry listener
|
void |
clear() |
boolean |
clearExpire()
Clear an expire timeout or expire date for object.
|
RFuture<Boolean> |
clearExpireAsync()
Clear an expire timeout or expire date for object in async mode.
|
protected RFuture<Boolean> |
clearExpireAsync(String... keys) |
RFuture<Boolean> |
containsKeyAsync(Object key)
Returns
true if this map contains map entry
mapped by specified key , otherwise false |
RFuture<Boolean> |
containsValueAsync(Object value)
Returns
true if this map contains any map entry
with specified value , otherwise false |
RFuture<Boolean> |
deleteAsync()
Delete object in async mode
|
void |
destroy()
Destroys object when it's not necessary anymore.
|
boolean |
expire(Instant instant)
Set an expire date for object.
|
boolean |
expire(long timeToLive,
TimeUnit timeUnit)
Set a timeout for object.
|
RFuture<Boolean> |
expireAsync(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) |
boolean |
expireAt(Date timestamp)
Use
RExpirable.expire(Instant) instead |
boolean |
expireAt(long timestamp)
Use
RExpirable.expire(Instant) instead |
RFuture<Boolean> |
expireAtAsync(Date timestamp)
Use
RExpirableAsync.expireAsync(Instant) instead |
RFuture<Boolean> |
expireAtAsync(long timestamp)
Use
RExpirableAsync.expireAsync(Instant) instead |
protected RFuture<Boolean> |
expireAtAsync(long timestamp,
String... keys) |
boolean |
fastPut(K key,
V value,
long ttl,
TimeUnit ttlUnit)
Stores value mapped by key with specified time to live.
|
boolean |
fastPut(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.
|
RFuture<Boolean> |
fastPutAsync(K key,
V value,
long ttl,
TimeUnit ttlUnit)
Stores value mapped by key with specified time to live.
|
RFuture<Boolean> |
fastPutAsync(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.
|
boolean |
fastPutIfAbsent(K key,
V value,
long ttl,
TimeUnit ttlUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
boolean |
fastPutIfAbsent(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
RFuture<Boolean> |
fastPutIfAbsentAsync(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
protected RFuture<Boolean> |
fastPutIfAbsentOperationAsync(K key,
V value) |
protected RFuture<Boolean> |
fastPutIfExistsOperationAsync(K key,
V value) |
protected RFuture<Boolean> |
fastPutOperationAsync(K key,
V value) |
protected RFuture<Boolean> |
fastPutOperationAsync(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit) |
protected RFuture<Long> |
fastRemoveOperationAsync(K... keys) |
protected RFuture<List<Long>> |
fastRemoveOperationBatchAsync(K... keys) |
protected RFuture<Boolean> |
fastReplaceOperationAsync(K key,
V value) |
RFuture<Map<K,V>> |
getAllOperationAsync(Set<K> keys) |
RFuture<V> |
getOperationAsync(K key) |
V |
put(K key,
V value,
long ttl,
TimeUnit unit)
Stores value mapped by key with specified time to live.
|
V |
put(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.
|
void |
putAll(Map<? extends K,? extends V> map,
long ttl,
TimeUnit ttlUnit)
Associates the specified
value with the specified key
in batch. |
RFuture<Void> |
putAllAsync(Map<? extends K,? extends V> map,
long ttl,
TimeUnit ttlUnit)
Associates the specified
value with the specified key
in batch. |
protected RFuture<Void> |
putAllOperationAsync(Map<? extends K,? extends V> map) |
RFuture<V> |
putAsync(K key,
V value,
long ttl,
TimeUnit ttlUnit)
Stores value mapped by key with specified time to live.
|
RFuture<V> |
putAsync(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
Stores value mapped by key with specified time to live and max idle time.
|
V |
putIfAbsent(K key,
V value,
long ttl,
TimeUnit ttlUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
V |
putIfAbsent(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
RFuture<V> |
putIfAbsentAsync(K key,
V value,
long ttl,
TimeUnit ttlUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
RFuture<V> |
putIfAbsentAsync(K key,
V value,
long ttl,
TimeUnit ttlUnit,
long maxIdleTime,
TimeUnit maxIdleUnit)
If the specified key is not already associated
with a value, associate it with the given value.
|
protected RFuture<V> |
putIfAbsentOperationAsync(K key,
V value) |
protected RFuture<V> |
putIfExistsOperationAsync(K key,
V value) |
protected RFuture<V> |
putOperationAsync(K key,
V value) |
protected RFuture<V> |
putOperationAsync(K key,
V value,
long ttlTimeout,
long maxIdleTimeout,
long maxIdleDelta,
long ttlTimeoutDelta) |
RFuture<Map<K,V>> |
randomEntriesAsync(int count)
Returns random map entries from this map limited by
count |
RFuture<Set<K>> |
randomKeysAsync(int count)
Returns random keys from this map limited by
count |
RFuture<Set<Map.Entry<K,V>>> |
readAllEntrySetAsync()
Read all map entries at once
|
RFuture<Set<K>> |
readAllKeySetAsync()
Read all keys at once
|
RFuture<Map<K,V>> |
readAllMapAsync()
Read all map as local instance at once
|
RFuture<Collection<V>> |
readAllValuesAsync()
Read all values at once
|
long |
remainTimeToLive()
Remaining time to live of Redisson object that has a timeout
|
long |
remainTimeToLive(K key)
Remaining time to live of map entry associated with a
key . |
RFuture<Long> |
remainTimeToLiveAsync()
Remaining time to live of Redisson object that has a timeout
|
RFuture<Long> |
remainTimeToLiveAsync(K key)
Remaining time to live of map entry associated with a
key . |
void |
removeListener(int listenerId)
Removes object event listener
|
protected RFuture<V> |
removeOperationAsync(K key) |
protected RFuture<Boolean> |
removeOperationAsync(Object key,
Object value) |
protected RFuture<V> |
replaceOperationAsync(K key,
V value) |
protected RFuture<Boolean> |
replaceOperationAsync(K key,
V oldValue,
V newValue) |
MapScanResult<Object,Object> |
scanIterator(String name,
RedisClient client,
long startPos,
String pattern,
int count) |
RFuture<MapScanResult<Object,Object>> |
scanIteratorAsync(String name,
RedisClient client,
long startPos,
String pattern,
int count) |
void |
setMaxSize(int maxSize)
Sets max size of the map and overrides current value.
|
void |
setMaxSize(int maxSize,
EvictionMode mode)
Sets max size of the map and overrides current value.
|
RFuture<Void> |
setMaxSizeAsync(int maxSize)
Sets max size of the map and overrides current value.
|
RFuture<Void> |
setMaxSizeAsync(int maxSize,
EvictionMode mode)
Sets max size of the map and overrides current value.
|
RFuture<Long> |
sizeInMemoryAsync()
Returns bytes amount used by object in Redis memory.
|
boolean |
trySetMaxSize(int maxSize)
Tries to set max size of the map.
|
boolean |
trySetMaxSize(int maxSize,
EvictionMode mode)
Tries to set max size of the map.
|
RFuture<Boolean> |
trySetMaxSizeAsync(int maxSize)
Tries to set max size of the map.
|
RFuture<Boolean> |
trySetMaxSizeAsync(int maxSize,
EvictionMode mode)
Tries to set max size of the map.
|
addAndGetAsync, checkKey, checkValue, compute, computeAsync, computeIfAbsent, computeIfAbsentAsync, computeIfPresent, computeIfPresentAsync, containsKey, 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, 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
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, getName, 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
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
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
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
clearExpire, expire, expire, expireAt, expireAt, remainTimeToLive
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
sizeAsync
addAndGetAsync, computeAsync, computeIfAbsentAsync, computeIfPresentAsync, fastPutAsync, fastPutIfAbsentAsync, fastPutIfExistsAsync, fastRemoveAsync, fastReplaceAsync, getAllAsync, getAsync, loadAllAsync, loadAllAsync, mergeAsync, putAllAsync, putAllAsync, putAsync, putIfAbsentAsync, putIfExistsAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, valueSizeAsync
expireAsync, expireAtAsync, remainTimeToLiveAsync
addListenerAsync, copyAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, touchAsync, unlinkAsync
public RedissonMapCache(EvictionScheduler evictionScheduler, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options, WriteBehindService writeBehindService)
public RedissonMapCache(Codec codec, EvictionScheduler evictionScheduler, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K,V> options, WriteBehindService writeBehindService)
public boolean trySetMaxSize(int maxSize)
RMapCache
trySetMaxSize
in interface RMapCache<K,V>
maxSize
- - max sizetrue
if max size has been successfully set, otherwise false
.
If 0
the cache is unbounded (default).public boolean trySetMaxSize(int maxSize, EvictionMode mode)
RMapCache
trySetMaxSize
in interface RMapCache<K,V>
maxSize
- - max sizemode
- - eviction modetrue
if max size has been successfully set, otherwise false
.public RFuture<Boolean> trySetMaxSizeAsync(int maxSize)
RMapCacheAsync
trySetMaxSizeAsync
in interface RMapCacheAsync<K,V>
maxSize
- - max sizetrue
if max size has been successfully set, otherwise false
.public RFuture<Boolean> trySetMaxSizeAsync(int maxSize, EvictionMode mode)
RMapCacheAsync
trySetMaxSizeAsync
in interface RMapCacheAsync<K,V>
maxSize
- - max sizemode
- - eviction modetrue
if max size has been successfully set, otherwise false
.public void setMaxSize(int maxSize)
RMapCache
setMaxSize
in interface RMapCache<K,V>
maxSize
- - max size
If 0
the cache is unbounded (default).public void setMaxSize(int maxSize, EvictionMode mode)
RMapCache
setMaxSize
in interface RMapCache<K,V>
maxSize
- - max sizemode
- - eviction modepublic RFuture<Void> setMaxSizeAsync(int maxSize)
RMapCacheAsync
setMaxSizeAsync
in interface RMapCacheAsync<K,V>
maxSize
- - max sizepublic RFuture<Void> setMaxSizeAsync(int maxSize, EvictionMode mode)
RMapCacheAsync
setMaxSizeAsync
in interface RMapCacheAsync<K,V>
maxSize
- - max sizemode
- - eviction modepublic RFuture<Boolean> containsKeyAsync(Object key)
RMapAsync
true
if this map contains map entry
mapped by specified key
, otherwise false
containsKeyAsync
in interface RMapAsync<K,V>
containsKeyAsync
in class RedissonMap<K,V>
key
- - map keytrue
if this map contains map entry
mapped by specified key
, otherwise false
public RFuture<Boolean> containsValueAsync(Object value)
RMapAsync
true
if this map contains any map entry
with specified value
, otherwise false
containsValueAsync
in interface RMapAsync<K,V>
containsValueAsync
in class RedissonMap<K,V>
value
- - map valuetrue
if this map contains any map entry
with specified value
, otherwise false
public RFuture<Map<K,V>> getAllOperationAsync(Set<K> keys)
getAllOperationAsync
in class RedissonMap<K,V>
public V putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
RMapCache
Stores value mapped by key with specified time to live. Entry expires after specified time to live.
putIfAbsent
in interface RMapCache<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then stores infinitely.ttlUnit
- - time unitpublic RFuture<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit)
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.
putIfAbsentAsync
in interface RMapCacheAsync<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then stores infinitely.ttlUnit
- - time unitpublic V putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
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.
putIfAbsent
in interface RMapCache<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry.
If 0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unit
if maxIdleTime
and ttl
params are equal to 0
then entry stores infinitely.
public RFuture<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
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.
putIfAbsentAsync
in interface RMapCacheAsync<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry.
If 0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unit
if maxIdleTime
and ttl
params are equal to 0
then entry stores infinitely.
protected RFuture<Boolean> removeOperationAsync(Object key, Object value)
removeOperationAsync
in class RedissonMap<K,V>
public RFuture<V> getOperationAsync(K key)
getOperationAsync
in class RedissonMap<K,V>
public V put(K key, V value, long ttl, TimeUnit unit)
RMapCache
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
protected RFuture<V> putOperationAsync(K key, V value)
putOperationAsync
in class RedissonMap<K,V>
protected RFuture<V> putIfExistsOperationAsync(K key, V value)
putIfExistsOperationAsync
in class RedissonMap<K,V>
protected RFuture<V> putIfAbsentOperationAsync(K key, V value)
putIfAbsentOperationAsync
in class RedissonMap<K,V>
public void putAll(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
RMapCache
value
with the specified key
in batch.
If MapWriter
is defined then new map entries will be stored in write-through mode.
public RFuture<Void> putAllAsync(Map<? extends K,? extends V> map, long ttl, TimeUnit ttlUnit)
RMapCache
value
with the specified key
in batch.
If MapWriter
is defined then new map entries are stored in write-through mode.
putAllAsync
in interface RMapCache<K,V>
map
- - mappings to be stored in this mapttl
- - time to live for all key\value entries.
If 0
then stores infinitely.ttlUnit
- - time unitpublic V addAndGet(K key, Number value)
RMap
delta
to the current value
by mapped key
.
Works only for numeric values!protected RFuture<V> addAndGetOperationAsync(K key, Number value)
addAndGetOperationAsync
in class RedissonMap<K,V>
public boolean fastPut(K key, V value, long ttl, TimeUnit ttlUnit)
RMapCache
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.
fastPut
in interface RMapCache<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then stores infinitely.ttlUnit
- - time unittrue
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.public RFuture<Boolean> fastPutAsync(K key, V value, long ttl, TimeUnit ttlUnit)
RMapCacheAsync
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.
fastPutAsync
in interface RMapCacheAsync<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then stores infinitely.ttlUnit
- - time unittrue
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.public boolean fastPut(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
RMapCache
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.
fastPut
in interface RMapCache<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry.
If 0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unit
if maxIdleTime
and ttl
params are equal to 0
then entry stores infinitely.
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.public RFuture<Boolean> fastPutAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
RMapCacheAsync
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.
fastPutAsync
in interface RMapCacheAsync<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry.
If 0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unit
if maxIdleTime
and ttl
params are equal to 0
then entry stores infinitely.
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.protected RFuture<Boolean> fastPutOperationAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
public RFuture<V> putAsync(K key, V value, long ttl, TimeUnit ttlUnit)
RMapCacheAsync
putAsync
in interface RMapCacheAsync<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then stores infinitely.ttlUnit
- - time unitpublic V put(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
RMapCache
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
put
in interface RMapCache<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry.
If 0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unit
if maxIdleTime
and ttl
params are equal to 0
then entry stores infinitely.
public RFuture<V> putAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
RMapCacheAsync
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
putAsync
in interface RMapCacheAsync<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry.
If 0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unit
if maxIdleTime
and ttl
params are equal to 0
then entry stores infinitely.
protected RFuture<V> putOperationAsync(K key, V value, long ttlTimeout, long maxIdleTimeout, long maxIdleDelta, long ttlTimeoutDelta)
public long remainTimeToLive(K key)
RMapCache
key
.remainTimeToLive
in interface RMapCache<K,V>
key
- - map keypublic RFuture<Long> remainTimeToLiveAsync(K key)
RMapCacheAsync
key
.remainTimeToLiveAsync
in interface RMapCacheAsync<K,V>
key
- - map keyprotected RFuture<V> removeOperationAsync(K key)
removeOperationAsync
in class RedissonMap<K,V>
protected RFuture<List<Long>> fastRemoveOperationBatchAsync(K... keys)
fastRemoveOperationBatchAsync
in class RedissonMap<K,V>
protected RFuture<Long> fastRemoveOperationAsync(K... keys)
fastRemoveOperationAsync
in class RedissonMap<K,V>
public MapScanResult<Object,Object> scanIterator(String name, RedisClient client, long startPos, String pattern, int count)
scanIterator
in class RedissonMap<K,V>
public RFuture<MapScanResult<Object,Object>> scanIteratorAsync(String name, RedisClient client, long startPos, String pattern, int count)
scanIteratorAsync
in class RedissonMap<K,V>
protected RFuture<Boolean> fastPutOperationAsync(K key, V value)
fastPutOperationAsync
in class RedissonMap<K,V>
protected RFuture<Boolean> fastPutIfExistsOperationAsync(K key, V value)
fastPutIfExistsOperationAsync
in class RedissonMap<K,V>
protected RFuture<Boolean> fastPutIfAbsentOperationAsync(K key, V value)
fastPutIfAbsentOperationAsync
in class RedissonMap<K,V>
public boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
RMapCache
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.
fastPutIfAbsent
in interface RMapCache<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then stores infinitely.ttlUnit
- - time unittrue
if key is a new key in the hash and value was set.
false
if key already exists in the hashpublic boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
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.
Works faster than usual RMapCache.putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.
fastPutIfAbsent
in interface RMapCache<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry.
If 0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unit
if maxIdleTime
and ttl
params are equal to 0
then entry stores infinitely.
true
if key is a new key in the hash and value was set.
false
if key already exists in the hash.public RFuture<Boolean> fastPutIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
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.
Works faster than usual RMapCacheAsync.putIfAbsentAsync(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.
fastPutIfAbsentAsync
in interface RMapCacheAsync<K,V>
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then time to live doesn't affect entry expiration.ttlUnit
- - time unitmaxIdleTime
- - max idle time for key\value entry.
If 0
then max idle time doesn't affect entry expiration.maxIdleUnit
- - time unit
if maxIdleTime
and ttl
params are equal to 0
then entry stores infinitely.
true
if key is a new key in the hash and value was set.
false
if key already exists in the hashprotected RFuture<Boolean> replaceOperationAsync(K key, V oldValue, V newValue)
replaceOperationAsync
in class RedissonMap<K,V>
protected RFuture<Boolean> fastReplaceOperationAsync(K key, V value)
fastReplaceOperationAsync
in class RedissonMap<K,V>
protected RFuture<V> replaceOperationAsync(K key, V value)
replaceOperationAsync
in class RedissonMap<K,V>
protected RFuture<Void> putAllOperationAsync(Map<? extends K,? extends V> map)
putAllOperationAsync
in class RedissonMap<K,V>
public int addListener(MapEntryListener listener)
RMapCache
addListener
in interface RMapCache<K,V>
listener
- - entry listenerEntryCreatedListener
,
EntryUpdatedListener
,
EntryRemovedListener
,
EntryExpiredListener
public void removeListener(int listenerId)
RObject
removeListener
in interface RMapCache<K,V>
removeListener
in interface RObject
removeListener
in class RedissonObject
listenerId
- - listener idpublic RFuture<Long> sizeInMemoryAsync()
RObjectAsync
sizeInMemoryAsync
in interface RObjectAsync
sizeInMemoryAsync
in class RedissonObject
public void clear()
public RFuture<Boolean> deleteAsync()
RObjectAsync
deleteAsync
in interface RObjectAsync
deleteAsync
in class RedissonObject
true
if object was deleted false
if notpublic RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
RExpirableAsync
expireAsync
in interface RExpirableAsync
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unittrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAtAsync(long timestamp)
RExpirableAsync
RExpirableAsync.expireAsync(Instant)
insteadexpireAtAsync
in interface RExpirableAsync
timestamp
- - expire date in milliseconds (Unix timestamp)true
if the timeout was set and false
if notpublic RFuture<Boolean> clearExpireAsync()
RExpirableAsync
clearExpireAsync
in interface RExpirableAsync
true
if the timeout was cleared and false
if notpublic RFuture<Set<K>> readAllKeySetAsync()
RMapAsync
readAllKeySetAsync
in interface RMapAsync<K,V>
readAllKeySetAsync
in class RedissonMap<K,V>
public RFuture<Set<K>> randomKeysAsync(int count)
RMapAsync
count
randomKeysAsync
in interface RMapAsync<K,V>
randomKeysAsync
in class RedissonMap<K,V>
count
- - keys amount to returnpublic RFuture<Map<K,V>> randomEntriesAsync(int count)
RMapAsync
count
randomEntriesAsync
in interface RMapAsync<K,V>
randomEntriesAsync
in class RedissonMap<K,V>
count
- - entries amount to returnpublic RFuture<Set<Map.Entry<K,V>>> readAllEntrySetAsync()
RMapAsync
readAllEntrySetAsync
in interface RMapAsync<K,V>
readAllEntrySetAsync
in class RedissonMap<K,V>
public RFuture<Map<K,V>> readAllMapAsync()
RMapAsync
readAllMapAsync
in interface RMapAsync<K,V>
readAllMapAsync
in class RedissonMap<K,V>
public RFuture<Collection<V>> readAllValuesAsync()
RMapAsync
readAllValuesAsync
in interface RMapAsync<K,V>
readAllValuesAsync
in class RedissonMap<K,V>
public void destroy()
RDestroyable
destroy
in interface RDestroyable
public boolean expire(long timeToLive, TimeUnit timeUnit)
RExpirable
expire
in interface RExpirable
timeToLive
- - timeout before object will be deletedtimeUnit
- - timeout time unittrue
if the timeout was set and false
if notpublic boolean expireAt(long timestamp)
RExpirable
RExpirable.expire(Instant)
insteadexpireAt
in interface RExpirable
timestamp
- - expire date in milliseconds (Unix timestamp)true
if the timeout was set and false
if notpublic boolean expire(Instant instant)
RExpirable
expire
in interface RExpirable
instant
- - expire datetrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAsync(Instant instant)
RExpirableAsync
expireAsync
in interface RExpirableAsync
instant
- - expire datetrue
if the timeout was set and false
if notpublic boolean expireAt(Date timestamp)
RExpirable
RExpirable.expire(Instant)
insteadexpireAt
in interface RExpirable
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic RFuture<Boolean> expireAtAsync(Date timestamp)
RExpirableAsync
RExpirableAsync.expireAsync(Instant)
insteadexpireAtAsync
in interface RExpirableAsync
timestamp
- - expire datetrue
if the timeout was set and false
if notpublic boolean clearExpire()
RExpirable
clearExpire
in interface RExpirable
true
if timeout was removed
false
if object does not exist or does not have an associated timeoutpublic long remainTimeToLive()
RExpirable
remainTimeToLive
in interface RExpirable
public RFuture<Long> remainTimeToLiveAsync()
RExpirableAsync
remainTimeToLiveAsync
in interface RExpirableAsync
protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String... keys)
Copyright © 2014–2021 Redisson. All rights reserved.