Interface RMap<K,V>
-
- Type Parameters:
K- map keyV- value
- All Superinterfaces:
ConcurrentMap<K,V>,Map<K,V>,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
public interface RMap<K,V> extends ConcurrentMap<K,V>, RExpirable, RMapAsync<K,V>
Redis based implementation ofConcurrentMapandMapThis map uses serialized state of key instead of hashCode or equals methods. This map doesn't allow to store
nullas key or value.- Author:
- Nikita Koksharov
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description VaddAndGet(K key, Number delta)Adds the givendeltato the current value by mappedkey.booleancontainsKey(Object key)Returnstrueif this map contains map entry mapped by specifiedkey, otherwisefalsebooleancontainsValue(Object value)Returnstrueif this map contains any map entry with specifiedvalue, otherwisefalseSet<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.booleanfastPut(K key, V value)Stores the specifiedvaluemapped by specifiedkey.booleanfastPutIfAbsent(K key, V value)Stores the specifiedvaluemapped by specifiedkeyonly if there is no value with specifiedkeystored before.booleanfastPutIfExists(K key, V value)Stores the specifiedvaluemapped bykeyonly if mapping already exists.longfastRemove(K... keys)Removes map entries mapped by specifiedkeys.booleanfastReplace(K key, V value)Replaces previous value with a newvaluemapped by specifiedkey.Vget(Object key)Returns the value mapped by definedkeyornullif value is absent.Map<K,V>getAll(Set<K> keys)Returns map slice contained the mappings with definedkeys.RCountDownLatchgetCountDownLatch(K key)ReturnsRCountDownLatchinstance associated with keyRLockgetFairLock(K key)ReturnsRLockinstance associated with keyRLockgetLock(K key)ReturnsRLockinstance associated with keyRPermitExpirableSemaphoregetPermitExpirableSemaphore(K key)ReturnsRPermitExpirableSemaphoreinstance associated with keyRReadWriteLockgetReadWriteLock(K key)ReturnsRReadWriteLockinstance associated with keyRSemaphoregetSemaphore(K key)ReturnsRSemaphoreinstance associated with keySet<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.voidloadAll(boolean replaceExistingValues, int parallelism)Loads all map entries to this Redis map usingMapLoader.voidloadAll(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)Loads map entries usingMapLoaderwhose keys are listed in definedkeysparameter.<KOut,VOut>
RMapReduce<K,V,KOut,VOut>mapReduce()ReturnsRMapReduceobject associated with this mapVput(K key, V value)Stores the specifiedvaluemapped by specifiedkey.voidputAll(Map<? extends K,? extends V> map)Stores map entries specified inmapobject in batch mode.voidputAll(Map<? extends K,? extends V> map, int batchSize)Stores map entries specified inmapobject in batch mode.VputIfAbsent(K key, V value)Stores the specifiedvaluemapped bykeyonly if there is no value with specifiedkeystored before.VputIfExists(K key, V value)Stores the specifiedvaluemapped bykeyonly if mapping already exists.Map<K,V>randomEntries(int count)Returns random map entries from this map limited bycountSet<K>randomKeys(int count)Returns random keys from this map limited bycountSet<Map.Entry<K,V>>readAllEntrySet()Read all map entries at onceSet<K>readAllKeySet()Read all keys at onceMap<K,V>readAllMap()Read all map as local instance at onceCollection<V>readAllValues()Read all values at onceVremove(Object key)Removes map entry by specifiedkeyand returns value.booleanremove(Object key, Object value)Removes map entry only if it exists with specifiedkeyandvalue.Vreplace(K key, V value)Replaces previous value with a newvaluemapped by specifiedkey.booleanreplace(K key, V oldValue, V newValue)Replaces previousoldValuewith anewValuemapped by specifiedkey.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.intvalueSize(K key)Returns size of value mapped by specifiedkeyin bytes-
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.RMapAsync
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
-
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, deleteAsync, dumpAsync, getIdleTimeAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
-
-
-
Method Detail
-
loadAll
void loadAll(boolean replaceExistingValues, int parallelism)Loads all map entries to this Redis map usingMapLoader.- Parameters:
replaceExistingValues- -trueif existed values should be replaced,falseotherwise.parallelism- - parallelism level, used to increase speed of process execution
-
loadAll
void loadAll(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
Loads map entries usingMapLoaderwhose keys are listed in definedkeysparameter.- Parameters:
keys- - map keysreplaceExistingValues- -trueif existed values should be replaced,falseotherwise.parallelism- - parallelism level, used to increase speed of process execution
-
get
V get(Object key)
Returns the value mapped by definedkeyornullif value is absent.If map doesn't contain value for specified key and
MapLoaderis defined then value will be loaded in read-through mode.
-
put
V put(K key, V value)
Stores the specifiedvaluemapped by specifiedkey. Returns previous value if map entry with specifiedkeyalready existed.If
MapWriteris defined then map entry is stored in write-through mode.
-
putIfAbsent
V putIfAbsent(K key, V value)
Stores the specifiedvaluemapped bykeyonly if there is no value with specifiedkeystored before.If
MapWriteris defined then new map entry is stored in write-through mode.- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
putIfAbsentin interfaceMap<K,V>- Parameters:
key- - map keyvalue- - map value- Returns:
nullif 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
V putIfExists(K key, V value)
Stores the specifiedvaluemapped bykeyonly if mapping already exists.If
MapWriteris defined then new map entry is stored in write-through mode.- Parameters:
key- - map keyvalue- - map value- Returns:
nullif 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
Set<K> randomKeys(int count)
Returns random keys from this map limited bycount- Parameters:
count- - keys amount to return- Returns:
- random keys
-
randomEntries
Map<K,V> randomEntries(int count)
Returns random map entries from this map limited bycount- Parameters:
count- - entries amount to return- Returns:
- random entries
-
mapReduce
<KOut,VOut> RMapReduce<K,V,KOut,VOut> mapReduce()
ReturnsRMapReduceobject associated with this map- Type Parameters:
KOut- output keyVOut- output value- Returns:
- MapReduce instance
-
getCountDownLatch
RCountDownLatch getCountDownLatch(K key)
ReturnsRCountDownLatchinstance associated with key- Parameters:
key- - map key- Returns:
- countdownlatch
-
getPermitExpirableSemaphore
RPermitExpirableSemaphore getPermitExpirableSemaphore(K key)
ReturnsRPermitExpirableSemaphoreinstance associated with key- Parameters:
key- - map key- Returns:
- permitExpirableSemaphore
-
getSemaphore
RSemaphore getSemaphore(K key)
ReturnsRSemaphoreinstance associated with key- Parameters:
key- - map key- Returns:
- semaphore
-
getFairLock
RLock getFairLock(K key)
ReturnsRLockinstance associated with key- Parameters:
key- - map key- Returns:
- fairlock
-
getReadWriteLock
RReadWriteLock getReadWriteLock(K key)
ReturnsRReadWriteLockinstance associated with key- Parameters:
key- - map key- Returns:
- readWriteLock
-
getLock
RLock getLock(K key)
ReturnsRLockinstance associated with key- Parameters:
key- - map key- Returns:
- lock
-
valueSize
int valueSize(K key)
Returns size of value mapped by specifiedkeyin bytes- Parameters:
key- - map key- Returns:
- size of value
-
addAndGet
V addAndGet(K key, Number delta)
Adds the givendeltato the current value by mappedkey. Works only for numeric values!- Parameters:
key- - map keydelta- the value to add- Returns:
- the updated value
-
containsKey
boolean containsKey(Object key)
Returnstrueif this map contains map entry mapped by specifiedkey, otherwisefalse- Specified by:
containsKeyin interfaceMap<K,V>- Parameters:
key- - map key- Returns:
trueif this map contains map entry mapped by specifiedkey, otherwisefalse
-
containsValue
boolean containsValue(Object value)
Returnstrueif this map contains any map entry with specifiedvalue, otherwisefalse- Specified by:
containsValuein interfaceMap<K,V>- Parameters:
value- - map value- Returns:
trueif this map contains any map entry with specifiedvalue, otherwisefalse
-
remove
V remove(Object key)
Removes map entry by specifiedkeyand returns value.If
MapWriteris defined thenkeyis deleted in write-through mode.
-
replace
V replace(K key, V value)
Replaces previous value with a newvaluemapped by specifiedkey. Returnsnullif there is no map entry stored before and doesn't store new map entry.If
MapWriteris defined then newvalueis written in write-through mode.
-
replace
boolean replace(K key, V oldValue, V newValue)
Replaces previousoldValuewith anewValuemapped by specifiedkey. Returnsfalseif previous value doesn't exist or equal tooldValue.If
MapWriteris defined thennewValueis written in write-through mode.
-
remove
boolean remove(Object key, Object value)
Removes map entry only if it exists with specifiedkeyandvalue.If
MapWriteris defined thenkeyis deleted in write-through mode.
-
putAll
void putAll(Map<? extends K,? extends V> map)
Stores map entries specified inmapobject in batch mode.If
MapWriteris defined then map entries will be stored in write-through mode.
-
putAll
void putAll(Map<? extends K,? extends V> map, int batchSize)
Stores map entries specified inmapobject in batch mode. Batch inserted by chunks limited bybatchSizevalue to avoid OOM and/or Redis response timeout error for map with big size.If
MapWriteris 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
Map<K,V> getAll(Set<K> keys)
Returns map slice contained the mappings with definedkeys.If map doesn't contain value/values for specified key/keys and
MapLoaderis 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
long fastRemove(K... keys)
Removes map entries mapped by specifiedkeys.Works faster than
but not returning the value.remove(Object)If
MapWriteris defined thenkeysare 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
boolean fastPut(K key, V value)
Stores the specifiedvaluemapped by specifiedkey.Works faster than
but not returning previous value.put(Object, Object)Returns
trueif key is a new key in the hash and value was set orfalseif key already exists in the hash and the value was updated.If
MapWriteris defined then map entry is stored in write-through mode.- Parameters:
key- - map keyvalue- - map value- Returns:
trueif key is a new key in the hash and value was set.falseif key already exists in the hash and the value was updated.
-
fastReplace
boolean fastReplace(K key, V value)
Replaces previous value with a newvaluemapped by specifiedkey.Works faster than
but not returning the previous value.replace(Object, Object)Returns
trueif key exists and value was updated orfalseif key doesn't exists and value wasn't updated.If
MapWriteris defined then new map entry is stored in write-through mode.- Parameters:
key- - map keyvalue- - map value- Returns:
trueif key exists and value was updated.falseif key doesn't exists and value wasn't updated.
-
fastPutIfAbsent
boolean fastPutIfAbsent(K key, V value)
Stores the specifiedvaluemapped by specifiedkeyonly if there is no value with specifiedkeystored before.Returns
trueif key is a new one in the hash and value was set orfalseif 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)keyIf
MapWriteris defined then new map entry is stored in write-through mode.- Parameters:
key- - map keyvalue- - map value- Returns:
trueif key is a new one in the hash and value was set.falseif key already exists in the hash and change hasn't been made.
-
fastPutIfExists
boolean fastPutIfExists(K key, V value)
Stores the specifiedvaluemapped bykeyonly if mapping already exists.Returns
trueif key is a new one in the hash and value was set orfalseif 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)keyIf
MapWriteris defined then new map entry is stored in write-through mode.- Parameters:
key- - map keyvalue- - map value- Returns:
trueif key already exists in the hash and new value has been stored.falseif key doesn't exist in the hash and value hasn't been set.
-
readAllValues
Collection<V> readAllValues()
Read all values at once- Returns:
- values
-
keySet
Set<K> keySet()
Returns key set of this map. Keys are loaded in batch. Batch size is10.- Specified by:
keySetin interfaceMap<K,V>- Returns:
- key set
- See Also:
readAllKeySet()
-
keySet
Set<K> keySet(int count)
Returns key set of this map. Keys are loaded in batch. Batch size is defined bycountparam.- Parameters:
count- - size of keys batch- Returns:
- key set
- See Also:
readAllKeySet()
-
keySet
Set<K> keySet(String pattern, int count)
Returns key set of this map. Ifpatternis not null then only keys match this pattern are loaded. Keys are loaded in batch. Batch size is defined bycountparam.Use
org.redisson.client.codec.StringCodecfor 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:
readAllKeySet()
-
keySet
Set<K> keySet(String pattern)
Returns key set of this map. Ifpatternis not null then only keys match this pattern are loaded.Use
org.redisson.client.codec.StringCodecfor 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:
readAllKeySet()
-
values
Collection<V> values()
Returns values collection of this map. Values are loaded in batch. Batch size is10.- Specified by:
valuesin interfaceMap<K,V>- Returns:
- values collection
- See Also:
readAllValues()
-
values
Collection<V> values(String keyPattern)
Returns values collection of this map. Values are loaded in batch. Batch size is10. IfkeyPatternis not null then only values mapped by matched keys of this pattern are loaded.Use
org.redisson.client.codec.StringCodecfor 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:
readAllValues()
-
values
Collection<V> values(String keyPattern, int count)
Returns values collection of this map. Values are loaded in batch. Batch size is defined bycountparam. IfkeyPatternis not null then only values mapped by matched keys of this pattern are loaded.Use
org.redisson.client.codec.StringCodecfor 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:
readAllValues()
-
values
Collection<V> values(int count)
Returns values collection of this map. Values are loaded in batch. Batch size is defined bycountparam.- Parameters:
count- - size of values batch- Returns:
- values collection
- See Also:
readAllValues()
-
entrySet
Set<Map.Entry<K,V>> entrySet()
Returns map entries collection. Map entries are loaded in batch. Batch size is10.- Specified by:
entrySetin interfaceMap<K,V>- Returns:
- map entries collection
- See Also:
readAllEntrySet()
-
entrySet
Set<Map.Entry<K,V>> entrySet(String keyPattern)
Returns map entries collection. Map entries are loaded in batch. Batch size is10. IfkeyPatternis 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:
readAllEntrySet()
-
entrySet
Set<Map.Entry<K,V>> entrySet(String keyPattern, int count)
Returns map entries collection. Map entries are loaded in batch. Batch size is defined bycountparam. IfkeyPatternis 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:
readAllEntrySet()
-
entrySet
Set<Map.Entry<K,V>> entrySet(int count)
Returns map entries collection. Map entries are loaded in batch. Batch size is defined bycountparam.- Parameters:
count- - size of entries batch- Returns:
- map entries collection
- See Also:
readAllEntrySet()
-
-