Interface RMap<K,V>
- Type Parameters:
K
- map keyV
- value
- All Superinterfaces:
ConcurrentMap<K,
,V> Map<K,
,V> RDestroyable
,RExpirable
,RExpirableAsync
,RMapAsync<K,
,V> RObject
,RObjectAsync
- All Known Subinterfaces:
RLocalCachedMap<K,
,V> RMapCache<K,
V>
- All Known Implementing Classes:
RedissonLocalCachedMap
,RedissonMap
,RedissonMapCache
,RedissonTransactionalLocalCachedMap
,RedissonTransactionalMap
,RedissonTransactionalMapCache
ConcurrentMap
and Map
This map uses serialized state of key instead of hashCode or equals methods.
This map doesn't allow to store null
as key or value.
- Author:
- Nikita Koksharov
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds the givendelta
to the current value by mappedkey
.int
addListener
(ObjectListener listener) Adds object event listenerboolean
containsKey
(Object key) Returnstrue
if this map contains map entry mapped by specifiedkey
, otherwisefalse
boolean
containsValue
(Object value) Returnstrue
if this map contains any map entry with specifiedvalue
, otherwisefalse
entrySet()
Returns map entries collection.entrySet
(int count) Returns map entries collection.Returns map entries collection.Returns map entries collection.boolean
Stores the specifiedvalue
mapped by specifiedkey
.boolean
fastPutIfAbsent
(K key, V value) Stores the specifiedvalue
mapped by specifiedkey
only if there is no value with specifiedkey
stored before.boolean
fastPutIfExists
(K key, V value) Stores the specifiedvalue
mapped bykey
only if mapping already exists.long
fastRemove
(K... keys) Removes map entries mapped by specifiedkeys
.boolean
fastReplace
(K key, V value) Replaces previous value with a newvalue
mapped by specifiedkey
.Returns the value mapped by definedkey
ornull
if value is absent.Returns map slice contained the mappings with definedkeys
.getCountDownLatch
(K key) ReturnsRCountDownLatch
instance associated with keygetFairLock
(K key) ReturnsRLock
instance associated with keyReturnsRLock
instance associated with keyReturnsRPermitExpirableSemaphore
instance associated with keygetReadWriteLock
(K key) ReturnsRReadWriteLock
instance associated with keygetSemaphore
(K key) ReturnsRSemaphore
instance associated with keykeySet()
Returns key set of this map.keySet
(int count) Returns key set of this map.Returns key set of this map.Returns key set of this map.void
loadAll
(boolean replaceExistingValues, int parallelism) Loads all map entries to this Redis map usingMapLoader
.void
Loads map entries usingMapLoader
whose keys are listed in definedkeys
parameter.<KOut,
VOut>
RMapReduce<K,V, KOut, VOut> ReturnsRMapReduce
object associated with this mapStores the specifiedvalue
mapped by specifiedkey
.void
Stores map entries specified inmap
object in batch mode.void
Stores map entries specified inmap
object in batch mode.putIfAbsent
(K key, V value) Stores the specifiedvalue
mapped bykey
only if there is no value with specifiedkey
stored before.putIfExists
(K key, V value) Stores the specifiedvalue
mapped bykey
only if mapping already exists.randomEntries
(int count) Returns random map entries from this map limited bycount
randomKeys
(int count) Returns random keys from this map limited bycount
Read all map entries at onceRead all keys at onceRead all map as local instance at onceRead all values at onceRemoves map entry by specifiedkey
and returns value.boolean
Removes map entry only if it exists with specifiedkey
andvalue
.Replaces previous value with a newvalue
mapped by specifiedkey
.boolean
Replaces previousoldValue
with anewValue
mapped by specifiedkey
.values()
Returns values collection of this map.values
(int count) Returns values collection of this map.Returns values collection of this map.Returns values collection of this map.int
Returns size of value mapped by specifiedkey
in bytesMethods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
Methods inherited from interface org.redisson.api.RDestroyable
destroy
Methods inherited from interface org.redisson.api.RExpirable
clearExpire, expire, expire, expire, expireAt, expireAt, expireIfGreater, expireIfGreater, expireIfLess, expireIfLess, expireIfNotSet, expireIfNotSet, expireIfSet, expireIfSet, getExpireTime, remainTimeToLive
Methods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsync
Methods inherited from interface org.redisson.api.RMapAsync
addAndGetAsync, addListenerAsync, clearAsync, computeAsync, computeIfAbsentAsync, computeIfPresentAsync, containsKeyAsync, containsValueAsync, fastPutAsync, fastPutIfAbsentAsync, fastPutIfExistsAsync, fastRemoveAsync, fastReplaceAsync, getAllAsync, getAsync, loadAllAsync, loadAllAsync, mergeAsync, putAllAsync, putAllAsync, putAsync, putIfAbsentAsync, putIfExistsAsync, randomEntriesAsync, randomKeysAsync, readAllEntrySetAsync, readAllKeySetAsync, readAllMapAsync, readAllValuesAsync, removeAsync, removeAsync, replaceAsync, replaceAsync, sizeAsync, valueSizeAsync
Methods inherited from interface org.redisson.api.RObject
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
copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
Method Details
-
loadAll
void loadAll(boolean replaceExistingValues, int parallelism) Loads all map entries to this Redis map usingMapLoader
.- Parameters:
replaceExistingValues
- -true
if existed values should be replaced,false
otherwise.parallelism
- - parallelism level, used to increase speed of process execution
-
loadAll
Loads map entries usingMapLoader
whose keys are listed in definedkeys
parameter.- Parameters:
keys
- - map keysreplaceExistingValues
- -true
if existed values should be replaced,false
otherwise.parallelism
- - parallelism level, used to increase speed of process execution
-
get
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. -
put
Stores the specifiedvalue
mapped by specifiedkey
. Returns previous value if map entry with specifiedkey
already existed.If
MapWriter
is defined then map entry is stored in write-through mode. -
putIfAbsent
Stores the specifiedvalue
mapped bykey
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:
putIfAbsent
in interfaceConcurrentMap<K,
V> - Specified by:
putIfAbsent
in interfaceMap<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.
-
putIfExists
Stores the specifiedvalue
mapped bykey
only if mapping already exists.If
MapWriter
is defined then new map entry is stored in write-through mode.- Parameters:
key
- - map keyvalue
- - map value- Returns:
null
if key doesn't exist in the hash and value hasn't been set. Previous value if key already exists in the hash and new value has been stored.
-
randomKeys
Returns random keys from this map limited bycount
- Parameters:
count
- - keys amount to return- Returns:
- random keys
-
randomEntries
Returns random map entries from this map limited bycount
- Parameters:
count
- - entries amount to return- Returns:
- random entries
-
mapReduce
ReturnsRMapReduce
object associated with this map- Type Parameters:
KOut
- output keyVOut
- output value- Returns:
- MapReduce instance
-
getCountDownLatch
ReturnsRCountDownLatch
instance associated with key- Parameters:
key
- - map key- Returns:
- countdownlatch
-
getPermitExpirableSemaphore
ReturnsRPermitExpirableSemaphore
instance associated with key- Parameters:
key
- - map key- Returns:
- permitExpirableSemaphore
-
getSemaphore
ReturnsRSemaphore
instance associated with key- Parameters:
key
- - map key- Returns:
- semaphore
-
getFairLock
ReturnsRLock
instance associated with key- Parameters:
key
- - map key- Returns:
- fairlock
-
getReadWriteLock
ReturnsRReadWriteLock
instance associated with key- Parameters:
key
- - map key- Returns:
- readWriteLock
-
getLock
ReturnsRLock
instance associated with key- Parameters:
key
- - map key- Returns:
- lock
-
valueSize
Returns size of value mapped by specifiedkey
in bytes- Parameters:
key
- - map key- Returns:
- size of value
-
addAndGet
Adds the givendelta
to the current value by mappedkey
.Works only with codecs below
- Parameters:
key
- - map keydelta
- the value to add- Returns:
- the updated value
-
containsKey
Returnstrue
if this map contains map entry mapped by specifiedkey
, otherwisefalse
- Specified by:
containsKey
in interfaceMap<K,
V> - Parameters:
key
- - map key- Returns:
true
if this map contains map entry mapped by specifiedkey
, otherwisefalse
-
containsValue
Returnstrue
if this map contains any map entry with specifiedvalue
, otherwisefalse
- Specified by:
containsValue
in interfaceMap<K,
V> - Parameters:
value
- - map value- Returns:
true
if this map contains any map entry with specifiedvalue
, otherwisefalse
-
remove
Removes map entry by specifiedkey
and returns value.If
MapWriter
is defined thenkey
is deleted in write-through mode. -
replace
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. -
replace
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. -
remove
Removes map entry only if it exists with specifiedkey
andvalue
.If
MapWriter
is defined thenkey
is deleted in write-through mode. -
putAll
Stores map entries specified inmap
object in batch mode.If
MapWriter
is defined then map entries will be stored in write-through mode. -
putAll
Stores map entries specified inmap
object in batch mode. Batch inserted by chunks limited bybatchSize
value to avoid OOM and/or Redis response timeout error for map with big size.If
MapWriter
is defined then map entries are stored in write-through mode.- Parameters:
map
- mappings to be stored in this mapbatchSize
- - size of map entries batch
-
getAll
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.
- Parameters:
keys
- map keys- Returns:
- Map slice
-
fastRemove
Removes map entries mapped by specifiedkeys
.Works faster than
but not returning the value.remove(Object)
If
MapWriter
is defined thenkeys
are deleted in write-through mode.- Parameters:
keys
- - map keys- Returns:
- the number of keys that were removed from the hash, not including specified but non existing keys
-
fastPut
Stores the specifiedvalue
mapped by specifiedkey
.Works faster than
but not returning previous value.put(Object, Object)
Returns
true
if key is a new key in the hash and value was set orfalse
if key already exists in the hash and the value was updated.If
MapWriter
is defined then map entry is stored in write-through mode.- Parameters:
key
- - map keyvalue
- - map value- Returns:
true
if key is a new key in the hash and value was set.false
if key already exists in the hash and the value was updated.
-
fastReplace
Replaces previous value with a newvalue
mapped by specifiedkey
.Works faster than
but not returning the previous value.replace(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.- 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.
-
fastPutIfAbsent
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 withputIfAbsent(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- 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.
-
fastPutIfExists
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 withputIfExists(Object, Object)
key
If
MapWriter
is defined then new map entry is stored in write-through mode.- 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.
-
readAllKeySet
Read all keys at once- Returns:
- keys
-
readAllValues
Collection<V> readAllValues()Read all values at once- Returns:
- values
-
readAllEntrySet
Read all map entries at once- Returns:
- entries
-
readAllMap
Read all map as local instance at once- Returns:
- map
-
keySet
Returns key set of this map. Keys are loaded in batch. Batch size is10
. -
keySet
Returns key set of this map. Keys are loaded in batch. Batch size is defined bycount
param.- Parameters:
count
- - size of keys batch- Returns:
- key set
- See Also:
-
keySet
Returns key set of this map. Ifpattern
is not null then only keys match this pattern are loaded. Keys are loaded in batch. Batch size is defined bycount
param.Use
org.redisson.client.codec.StringCodec
for Map keys.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Parameters:
pattern
- - key patterncount
- - size of keys batch- Returns:
- key set
- See Also:
-
keySet
Returns key set of this map. Ifpattern
is not null then only keys match this pattern are loaded.Use
org.redisson.client.codec.StringCodec
for Map keys.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Parameters:
pattern
- - key pattern- Returns:
- key set
- See Also:
-
values
Collection<V> values()Returns values collection of this map. Values are loaded in batch. Batch size is10
. -
values
Returns values collection of this map. Values are loaded in batch. Batch size is10
. IfkeyPattern
is not null then only values mapped by matched keys of this pattern are loaded.Use
org.redisson.client.codec.StringCodec
for Map keys.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Parameters:
keyPattern
- - key pattern- Returns:
- values collection
- See Also:
-
values
Returns values collection of this map. Values are loaded in batch. Batch size is defined bycount
param. IfkeyPattern
is not null then only values mapped by matched keys of this pattern are loaded.Use
org.redisson.client.codec.StringCodec
for Map keys.Supported glob-style patterns:
h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Parameters:
keyPattern
- - key patterncount
- - size of values batch- Returns:
- values collection
- See Also:
-
values
Returns values collection of this map. Values are loaded in batch. Batch size is defined bycount
param.- Parameters:
count
- - size of values batch- Returns:
- values collection
- See Also:
-
entrySet
Returns map entries collection. Map entries are loaded in batch. Batch size is10
. -
entrySet
Returns map entries collection. Map entries are loaded in batch. Batch size is10
. IfkeyPattern
is not null then only entries mapped by matched keys of this pattern are loaded. Supported glob-style patterns:h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Parameters:
keyPattern
- - key pattern- Returns:
- map entries collection
- See Also:
-
entrySet
Returns map entries collection. Map entries are loaded in batch. Batch size is defined bycount
param. IfkeyPattern
is not null then only entries mapped by matched keys of this pattern are loaded. Supported glob-style patterns:h?llo subscribes to hello, hallo and hxllo
h*llo subscribes to hllo and heeeello
h[ae]llo subscribes to hello and hallo, but not hillo
- Parameters:
keyPattern
- - key patterncount
- - size of entries batch- Returns:
- map entries collection
- See Also:
-
entrySet
Returns map entries collection. Map entries are loaded in batch. Batch size is defined bycount
param.- Parameters:
count
- - size of entries batch- Returns:
- map entries collection
- See Also:
-
addListener
Adds object event listener- Specified by:
addListener
in interfaceRObject
- Parameters:
listener
- object event listener- Returns:
- listener id
- See Also:
-