K
- keyV
- valuepublic interface RMapCache<K,V> extends RMap<K,V>, RMapCacheAsync<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)
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.
Expired tasks cleaned by 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
.
Modifier and Type | Method and Description |
---|---|
int |
addListener(MapEntryListener listener)
Adds map entry listener
|
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.
|
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.
|
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.
|
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.
|
long |
remainTimeToLive(K key)
Remaining time to live of map entry associated with a
key . |
void |
removeListener(int listenerId)
Removes map entry listener
|
void |
setMaxSize(int maxSize)
Sets max size of the map.
|
int |
size()
Returns the number of entries in cache.
|
boolean |
trySetMaxSize(int maxSize)
Tries to set max size of the map.
|
addAndGet, entrySet, entrySet, entrySet, entrySet, fastPut, fastPutIfAbsent, fastRemove, fastReplace, get, getAll, getLock, getReadWriteLock, keySet, keySet, keySet, keySet, loadAll, loadAll, mapReduce, put, putAll, putIfAbsent, readAllEntrySet, readAllKeySet, readAllMap, readAllValues, remove, remove, replace, replace, values, values, values, values, valueSize
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
clear, containsKey, containsValue, equals, hashCode, isEmpty
clearExpire, expire, expireAt, expireAt, remainTimeToLive
copy, delete, dump, getCodec, getName, isExists, migrate, move, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, touch, unlink
fastPutAsync, fastPutAsync, fastPutIfAbsentAsync, putAsync, putAsync, putIfAbsentAsync, putIfAbsentAsync, remainTimeToLiveAsync, setMaxSizeAsync, sizeAsync, trySetMaxSizeAsync
addAndGetAsync, containsKeyAsync, containsValueAsync, fastPutAsync, fastPutIfAbsentAsync, fastRemoveAsync, fastReplaceAsync, getAllAsync, getAsync, loadAllAsync, loadAllAsync, putAllAsync, putAsync, putIfAbsentAsync, readAllEntrySetAsync, readAllKeySetAsync, readAllMapAsync, readAllValuesAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, valueSizeAsync
clearExpireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
copyAsync, deleteAsync, dumpAsync, isExistsAsync, migrateAsync, moveAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, touchAsync, unlinkAsync
void setMaxSize(int maxSize)
maxSize
- - max size
If 0
the cache is unbounded (default).boolean trySetMaxSize(int maxSize)
maxSize
- - max sizetrue
if max size has been successfully set, otherwise false
.
If 0
the cache is unbounded (default).V putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
Stores value mapped by key with specified time to live. Entry expires after specified time to live.
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then stores infinitely.ttlUnit
- - time unitV putIfAbsent(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. Entry expires when specified time to live or max idle time has expired.
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.
V put(K key, V value, long ttl, TimeUnit unit)
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
key
- - map keyvalue
- - map valuettl
- - time to live for key\value entry.
If 0
then stores infinitely.unit
- - time unitV put(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
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.
boolean fastPut(K key, V value, long ttl, TimeUnit ttlUnit)
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
Works faster than usual put(Object, Object, long, TimeUnit)
as it not returns previous value.
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.boolean fastPut(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
If the map previously contained a mapping for the key, the old value is replaced by the specified value.
Works faster than usual put(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.
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.boolean fastPutIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit)
Stores value mapped by key with specified time to live. Entry expires after specified time to live.
Works faster than usual putIfAbsent(Object, Object, long, TimeUnit)
as it not returns previous value.
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 hashboolean fastPutIfAbsent(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. Entry expires when specified time to live or max idle time has expired.
Works faster than usual putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)
as it not returns previous value.
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.int size()
int addListener(MapEntryListener listener)
listener
- - entry listenerEntryCreatedListener
,
EntryUpdatedListener
,
EntryRemovedListener
,
EntryExpiredListener
void removeListener(int listenerId)
listenerId
- - listener idlong remainTimeToLive(K key)
key
.key
- - map keyCopyright © 2014–2018 The Redisson Project. All rights reserved.