K
- map keyV
- valuepublic interface RMap<K,V> extends ConcurrentMap<K,V>, RExpirable, RMapAsync<K,V>
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.
Modifier and Type | Method and Description |
---|---|
V |
addAndGet(K key,
Number delta)
Adds the given
delta to the current value
by mapped key . |
boolean |
containsKey(Object key)
Returns
true if this map contains map entry
mapped by specified key , otherwise false |
boolean |
containsValue(Object value)
Returns
true if this map contains any map entry
with specified value , otherwise false |
Set<Map.Entry<K,V>> |
entrySet()
Returns map entries collection.
|
Set<Map.Entry<K,V>> |
entrySet(int count)
Returns map entries collection.
|
Set<Map.Entry<K,V>> |
entrySet(String keyPattern)
Returns map entries collection.
|
Set<Map.Entry<K,V>> |
entrySet(String keyPattern,
int count)
Returns map entries collection.
|
boolean |
fastPut(K key,
V value)
Stores the specified
value mapped by specified key . |
boolean |
fastPutIfAbsent(K key,
V value)
Stores the specified
value mapped by specified key
only if there is no value with specifiedkey stored before. |
boolean |
fastPutIfExists(K key,
V value)
Stores the specified
value mapped by key
only if mapping already exists. |
long |
fastRemove(K... keys)
Removes map entries mapped by specified
keys . |
boolean |
fastReplace(K key,
V value)
Replaces previous value with a new
value mapped by specified key . |
V |
get(Object key)
Returns the value mapped by defined
key or null if value is absent. |
Map<K,V> |
getAll(Set<K> keys)
Returns map slice contained the mappings with defined
keys . |
RCountDownLatch |
getCountDownLatch(K key)
Returns
RCountDownLatch instance associated with key |
RLock |
getFairLock(K key)
Returns
RLock instance associated with key |
RLock |
getLock(K key)
Returns
RLock instance associated with key |
RPermitExpirableSemaphore |
getPermitExpirableSemaphore(K key)
Returns
RPermitExpirableSemaphore instance associated with key |
RReadWriteLock |
getReadWriteLock(K key)
Returns
RReadWriteLock instance associated with key |
RSemaphore |
getSemaphore(K key)
Returns
RSemaphore instance associated with key |
Set<K> |
keySet()
Returns key set of this map.
|
Set<K> |
keySet(int count)
Returns key set of this map.
|
Set<K> |
keySet(String pattern)
Returns key set of this map.
|
Set<K> |
keySet(String pattern,
int count)
Returns key set of this map.
|
void |
loadAll(boolean replaceExistingValues,
int parallelism)
Loads all map entries to this Redis map using
MapLoader . |
void |
loadAll(Set<? extends K> keys,
boolean replaceExistingValues,
int parallelism)
Loads map entries using
MapLoader whose keys are listed in defined keys parameter. |
<KOut,VOut> |
mapReduce()
Returns
RMapReduce object associated with this map |
V |
put(K key,
V value)
Stores the specified
value mapped by specified key . |
void |
putAll(Map<? extends K,? extends V> map)
Stores map entries specified in
map object in batch mode. |
void |
putAll(Map<? extends K,? extends V> map,
int batchSize)
Stores map entries specified in
map object in batch mode. |
V |
putIfAbsent(K key,
V value)
Stores the specified
value mapped by key
only if there is no value with specifiedkey stored before. |
V |
putIfExists(K key,
V value)
Stores the specified
value mapped by key
only if mapping already exists. |
Map<K,V> |
randomEntries(int count)
Returns random map entries from this map limited by
count |
Set<K> |
randomKeys(int count)
Returns random keys from this map limited by
count |
Set<Map.Entry<K,V>> |
readAllEntrySet()
Read all map entries at once
|
Set<K> |
readAllKeySet()
Read all keys at once
|
Map<K,V> |
readAllMap()
Read all map as local instance at once
|
Collection<V> |
readAllValues()
Read all values at once
|
V |
remove(Object key)
Removes map entry by specified
key and returns value. |
boolean |
remove(Object key,
Object value)
Removes map entry only if it exists with specified
key and value . |
V |
replace(K key,
V value)
Replaces previous value with a new
value mapped by specified key . |
boolean |
replace(K key,
V oldValue,
V newValue)
Replaces previous
oldValue with a newValue mapped by specified key . |
Collection<V> |
values()
Returns values collection of this map.
|
Collection<V> |
values(int count)
Returns values collection of this map.
|
Collection<V> |
values(String keyPattern)
Returns values collection of this map.
|
Collection<V> |
values(String keyPattern,
int count)
Returns values collection of this map.
|
int |
valueSize(K key)
Returns size of value mapped by specified
key in bytes |
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
clearExpire, expire, expire, expireAt, expireAt, remainTimeToLive
addListener, copy, delete, dump, getCodec, getIdleTime, getName, isExists, migrate, move, removeListener, rename, renamenx, restore, restore, restoreAndReplace, restoreAndReplace, sizeInMemory, touch, unlink
addAndGetAsync, 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
clearExpireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, remainTimeToLiveAsync
addListenerAsync, copyAsync, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
void loadAll(boolean replaceExistingValues, int parallelism)
MapLoader
.replaceExistingValues
- - true
if existed values should be replaced, false
otherwise.parallelism
- - parallelism level, used to increase speed of process executionvoid loadAll(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
MapLoader
whose keys are listed in defined keys
parameter.keys
- - map keysreplaceExistingValues
- - true
if existed values should be replaced, false
otherwise.parallelism
- - parallelism level, used to increase speed of process executionV get(Object key)
key
or null
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.
V put(K key, V value)
value
mapped by specified key
.
Returns previous value if map entry with specified key
already existed.
If MapWriter
is defined then map entry is stored in write-through mode.
V putIfAbsent(K key, V value)
value
mapped by key
only if there is no value with specifiedkey
stored before.
If MapWriter
is defined then new map entry is stored in write-through mode.
putIfAbsent
in interface ConcurrentMap<K,V>
putIfAbsent
in interface Map<K,V>
key
- - map keyvalue
- - map valuenull
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.V putIfExists(K key, V value)
value
mapped by key
only if mapping already exists.
If MapWriter
is defined then new map entry is stored in write-through mode.
key
- - map keyvalue
- - map valuenull
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.Set<K> randomKeys(int count)
count
count
- - keys amount to returnMap<K,V> randomEntries(int count)
count
count
- - entries amount to return<KOut,VOut> RMapReduce<K,V,KOut,VOut> mapReduce()
RMapReduce
object associated with this mapKOut
- output keyVOut
- output valueRCountDownLatch getCountDownLatch(K key)
RCountDownLatch
instance associated with keykey
- - map keyRPermitExpirableSemaphore getPermitExpirableSemaphore(K key)
RPermitExpirableSemaphore
instance associated with keykey
- - map keyRSemaphore getSemaphore(K key)
RSemaphore
instance associated with keykey
- - map keyRLock getFairLock(K key)
RLock
instance associated with keykey
- - map keyRReadWriteLock getReadWriteLock(K key)
RReadWriteLock
instance associated with keykey
- - map keyRLock getLock(K key)
RLock
instance associated with keykey
- - map keyint valueSize(K key)
key
in byteskey
- - map keyV addAndGet(K key, Number delta)
delta
to the current value
by mapped key
.
Works only for numeric values!key
- - map keydelta
- the value to addboolean containsKey(Object key)
true
if this map contains map entry
mapped by specified key
, otherwise false
containsKey
in interface Map<K,V>
key
- - map keytrue
if this map contains map entry
mapped by specified key
, otherwise false
boolean containsValue(Object value)
true
if this map contains any map entry
with specified value
, otherwise false
containsValue
in interface Map<K,V>
value
- - map valuetrue
if this map contains any map entry
with specified value
, otherwise false
V remove(Object key)
key
and returns value.
If MapWriter
is defined then key
is deleted in write-through mode.
V replace(K key, V value)
value
mapped by specified key
.
Returns null
if there is no map entry stored before and doesn't store new map entry.
If MapWriter
is defined then new value
is written in write-through mode.
boolean replace(K key, V oldValue, V newValue)
oldValue
with a newValue
mapped by specified key
.
Returns false
if previous value doesn't exist or equal to oldValue
.
If MapWriter
is defined then newValue
is written in write-through mode.
boolean remove(Object key, Object value)
key
and value
.
If MapWriter
is defined then key
is deleted in write-through mode.
void putAll(Map<? extends K,? extends V> map)
map
object in batch mode.
If MapWriter
is defined then map entries will be stored in write-through mode.
void putAll(Map<? extends K,? extends V> map, int batchSize)
map
object in batch mode.
Batch inserted by chunks limited by batchSize
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.
map
- mappings to be stored in this mapbatchSize
- - size of map entries batchMap<K,V> getAll(Set<K> keys)
keys
.
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.
keys
- - map keyslong fastRemove(K... keys)
keys
.
Works faster than
but not returning
the value.
remove(Object)
If MapWriter
is defined then keys
are deleted in write-through mode.
keys
- - map keysboolean fastPut(K key, V value)
value
mapped by specified key
.
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 or
false
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.
key
- - map keyvalue
- - map valuetrue
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 fastReplace(K key, V value)
value
mapped by specified key
.
Works faster than
but not returning
the previous value.
replace(Object, Object)
Returns true
if key exists and value was updated or
false
if key doesn't exists and value wasn't updated.
If MapWriter
is defined then new map entry is stored in write-through mode.
key
- - map keyvalue
- - map valuetrue
if key exists and value was updated.
false
if key doesn't exists and value wasn't updated.boolean fastPutIfAbsent(K key, V value)
value
mapped by specified key
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 or
false
if key already exists in the hash and change hasn't been made.
Works faster than
but not returning
the previous value associated with putIfAbsent(Object, Object)
key
If MapWriter
is defined then new map entry is stored in write-through mode.
key
- - map keyvalue
- - map valuetrue
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.boolean fastPutIfExists(K key, V value)
value
mapped by key
only if mapping already exists.
Returns true
if key is a new one in the hash and value was set or
false
if key already exists in the hash and change hasn't been made.
Works faster than
but doesn't return
previous value associated with putIfExists(Object, Object)
key
If MapWriter
is defined then new map entry is stored in write-through mode.
key
- - map keyvalue
- - map valuetrue
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.Collection<V> readAllValues()
Set<K> keySet()
10
.keySet
in interface Map<K,V>
readAllKeySet()
Set<K> keySet(int count)
count
param.count
- - size of keys batchreadAllKeySet()
Set<K> keySet(String pattern, int count)
pattern
is not null then only keys match this pattern are loaded.
Keys are loaded in batch. Batch size is defined by count
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
pattern
- - key patterncount
- - size of keys batchreadAllKeySet()
Set<K> keySet(String pattern)
pattern
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
pattern
- - key patternreadAllKeySet()
Collection<V> values()
10
.values
in interface Map<K,V>
readAllValues()
Collection<V> values(String keyPattern)
10
.
If keyPattern
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
keyPattern
- - key patternreadAllValues()
Collection<V> values(String keyPattern, int count)
count
param.
If keyPattern
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
keyPattern
- - key patterncount
- - size of values batchreadAllValues()
Collection<V> values(int count)
count
param.count
- - size of values batchreadAllValues()
Set<Map.Entry<K,V>> entrySet()
10
.entrySet
in interface Map<K,V>
readAllEntrySet()
Set<Map.Entry<K,V>> entrySet(String keyPattern)
10
.
If keyPattern
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
keyPattern
- - key patternreadAllEntrySet()
Set<Map.Entry<K,V>> entrySet(String keyPattern, int count)
count
param.
If keyPattern
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
keyPattern
- - key patterncount
- - size of entries batchreadAllEntrySet()
Set<Map.Entry<K,V>> entrySet(int count)
count
param.count
- - size of entries batchreadAllEntrySet()
Copyright © 2014–2021 Redisson. All rights reserved.