Interface RMapAsync<K,V>
- Type Parameters:
K- keyV- value
- All Superinterfaces:
RExpirableAsync,RObjectAsync
- All Known Subinterfaces:
RLocalCachedMap<K,,V> RLocalCachedMapCache<K,,V> RMap<K,,V> RMapCache<K,,V> RMapCacheAsync<K,,V> RMapCacheNative<K,,V> RMapCacheNativeAsync<K,V>
- All Known Implementing Classes:
MapCacheNativeWrapper,RedissonLocalCachedMap,RedissonMap,RedissonMapCache,RedissonMapCacheNative,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
-
Method Summary
Modifier and TypeMethodDescriptionaddAndGetAsync(K key, Number delta) Adds the givendeltato the current value by mappedkey.addListenerAsync(ObjectListener listener) Adds object event listenerClears map without removing options data used during map creation.computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) Computes a new mapping for the specified key and its current mapped value.computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction) Computes a mapping for the specified key if it's not mapped before.computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) Computes a mapping for the specified key only if it's already mapped.containsKeyAsync(Object key) Returnstrueif this map contains map entry mapped by specifiedkey, otherwisefalsecontainsValueAsync(Object value) Returnstrueif this map contains any map entry with specifiedvalue, otherwisefalseReturns map entries using iterable.entrySetAsync(int count) Returns map entries using iterable.entrySetAsync(String keyPattern) Returns map entries using iterable.entrySetAsync(String keyPattern, int count) Returns map entries using iterable.fastPutAsync(K key, V value) Stores the specifiedvaluemapped by specifiedkey.fastPutIfAbsentAsync(K key, V value) Stores the specifiedvaluemapped by specifiedkeyonly if there is no value with specifiedkeystored before.fastPutIfExistsAsync(K key, V value) Stores the specifiedvaluemapped bykeyonly if mapping already exists.fastRemoveAsync(K... keys) Removes map entries mapped by specifiedkeys.fastReplaceAsync(K key, V value) Replaces previous value with a newvaluemapped by specifiedkey.getAllAsync(Set<K> keys) Returns map slice contained the mappings with definedkeys.Returns the value mapped by definedkeyornullif value is absent.loadAllAsync(boolean replaceExistingValues, int parallelism) Loads all map entries to this Redis map usingMapLoader.loadAllAsync(Set<? extends K> keys, boolean replaceExistingValues, int parallelism) Loads map entries usingMapLoaderwhose keys are listed in definedkeysparameter.mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) Associates specified key with the given value if key isn't already associated with a value.putAllAsync(Map<? extends K, ? extends V> map) Stores map entries specified inmapobject in batch mode.putAllAsync(Map<? extends K, ? extends V> map, int batchSize) Stores map entries specified inmapobject in batch mode.Stores the specifiedvaluemapped by specifiedkey.putIfAbsentAsync(K key, V value) Stores the specifiedvaluemapped by specifiedkeyonly if there is no value with specifiedkeystored before.putIfExistsAsync(K key, V value) Stores the specifiedvaluemapped bykeyonly if mapping already exists.randomEntriesAsync(int count) Returns random map entries from this map limited bycountrandomKeysAsync(int count) Returns random keys from this map limited bycountRead all map entries at oncereadAllEntrySetAsync(String keyPattern) Read all entries mapped by matched keys of this pattern at onceRead all keys at oncereadAllKeySetAsync(String keyPattern) Read all keys mapped by matched keys of this pattern at onceRead all map as local instance at onceRead all values at oncereadAllValuesAsync(String keyPattern) Read all values mapped by matched keys of this pattern at onceremoveAsync(Object key, Object value) Removes map entry only if it exists with specifiedkeyandvalue.removeAsync(K key) Removes map entry by specifiedkeyand returns value.replaceAsync(K key, V value) Replaces previous value with a newvaluemapped by specifiedkey.replaceAsync(K key, V oldValue, V newValue) Replaces previousoldValuewith anewValuemapped by specifiedkey.Returns size of this mapReturns values of this map using iterable.valuesAsync(int count) Returns values of this map using iterable.valuesAsync(String keyPattern) Returns values of this map using iterable.valuesAsync(String keyPattern, int count) Returns values of this map using iterable.valueSizeAsync(K key) Returns size of value mapped by key in bytesMethods inherited from interface org.redisson.api.RExpirableAsync
clearExpireAsync, expireAsync, expireAsync, expireAsync, expireAtAsync, expireAtAsync, expireIfGreaterAsync, expireIfGreaterAsync, expireIfLessAsync, expireIfLessAsync, expireIfNotSetAsync, expireIfNotSetAsync, expireIfSetAsync, expireIfSetAsync, getExpireTimeAsync, remainTimeToLiveAsyncMethods inherited from interface org.redisson.api.RObjectAsync
copyAndReplaceAsync, copyAndReplaceAsync, copyAsync, copyAsync, copyAsync, deleteAsync, dumpAsync, getAccessFrequencyAsync, getIdleTimeAsync, getInternalEncodingAsync, getReferenceCountAsync, isExistsAsync, migrateAsync, moveAsync, removeListenerAsync, renameAsync, renamenxAsync, restoreAndReplaceAsync, restoreAndReplaceAsync, restoreAsync, restoreAsync, sizeInMemoryAsync, touchAsync, unlinkAsync
-
Method Details
-
mergeAsync
RFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) Associates specified key with the given value if key isn't already associated with a value. Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result isnull.- Parameters:
key- - map keyvalue- - value to be merged with the existing value associated with the key or to be associated with the key, if no existing valueremappingFunction- - the function is invoked with the existing value to compute new value- Returns:
- new value associated with the specified key or
nullif no value associated with the key
-
computeAsync
Computes a new mapping for the specified key and its current mapped value.- Parameters:
key- - map keyremappingFunction- - function to compute a value- Returns:
- the new value associated with the specified key, or
nullif none
-
computeIfAbsentAsync
Computes a mapping for the specified key if it's not mapped before.- Parameters:
key- - map keymappingFunction- - function to compute a value- Returns:
- current or new computed value associated with
the specified key, or
nullif the computed value is null
-
computeIfPresentAsync
RFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) Computes a mapping for the specified key only if it's already mapped.- Parameters:
key- - map keyremappingFunction- - function to compute a value- Returns:
- the new value associated with the specified key, or null if none
-
loadAllAsync
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- Returns:
- void
-
loadAllAsync
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- Returns:
- void
-
valueSizeAsync
Returns size of value mapped by key in bytes- Parameters:
key- - map key- Returns:
- size of value
-
getAllAsync
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
-
putAllAsync
Stores map entries specified inmapobject in batch mode.If
MapWriteris defined then map entries will be stored in write-through mode.- Parameters:
map- mappings to be stored in this map- Returns:
- void
-
putAllAsync
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- Returns:
- void
-
randomKeysAsync
Returns random keys from this map limited bycount- Parameters:
count- - keys amount to return- Returns:
- random keys
-
randomEntriesAsync
Returns random map entries from this map limited bycount- Parameters:
count- - entries amount to return- Returns:
- random entries
-
addAndGetAsync
Adds the givendeltato the current value by mappedkey.Works only with codecs below
- Parameters:
key- - map keydelta- the value to add- Returns:
- the updated value
-
containsValueAsync
Returnstrueif this map contains any map entry with specifiedvalue, otherwisefalse- Parameters:
value- - map value- Returns:
trueif this map contains any map entry with specifiedvalue, otherwisefalse
-
containsKeyAsync
Returnstrueif this map contains map entry mapped by specifiedkey, otherwisefalse- Parameters:
key- - map key- Returns:
trueif this map contains map entry mapped by specifiedkey, otherwisefalse
-
sizeAsync
Returns size of this map- Returns:
- size
-
valuesAsync
AsyncIterator<V> valuesAsync()Returns values of this map using iterable. Values are loaded in batch. Batch size is10.- Returns:
- Asynchronous Iterable object
-
valuesAsync
Returns values of this map using iterable. 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.Usage example:
Codec valueCodec = ... RMapinvalid input: '<'String, MyObject> map = redissonClient.getMap("simpleMap", new CompositeCodec(StringCodec.INSTANCE, valueCodec, valueCodec)); // or RMapinvalid input: '<'String, String> map = redissonClient.getMap("simpleMap", StringCodec.INSTANCE);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:
- Asynchronous Iterable object
-
valuesAsync
Returns values of this map using iterable. 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.Usage example:
Codec valueCodec = ... RMapinvalid input: '<'String, MyObject> map = redissonClient.getMap("simpleMap", new CompositeCodec(StringCodec.INSTANCE, valueCodec, valueCodec)); // or RMapinvalid input: '<'String, String> map = redissonClient.getMap("simpleMap", StringCodec.INSTANCE);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:
- Asynchronous Iterable object
-
valuesAsync
Returns values of this map using iterable. Values are loaded in batch. Batch size is defined bycountparam.- Parameters:
count- - size of values batch- Returns:
- Asynchronous Iterable object
-
entrySetAsync
AsyncIterator<Map.Entry<K,V>> entrySetAsync()Returns map entries using iterable. Map entries are loaded in batch. Batch size is10.- Returns:
- Asynchronous Iterable object
-
entrySetAsync
Returns map entries using iterable. Map entries are loaded in batch. Batch size is10. IfkeyPatternis not null then only entries mapped by matched keys of this pattern are loaded.Use
org.redisson.client.codec.StringCodecfor Map keys.Usage example:
Codec valueCodec = ... RMapinvalid input: '<'String, MyObject> map = redissonClient.getMap("simpleMap", new CompositeCodec(StringCodec.INSTANCE, valueCodec, valueCodec)); // or RMapinvalid input: '<'String, String> map = redissonClient.getMap("simpleMap", StringCodec.INSTANCE);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:
- Asynchronous Iterable object
-
entrySetAsync
Returns map entries using iterable. 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.Use
org.redisson.client.codec.StringCodecfor Map keys.Usage example:
Codec valueCodec = ... RMapinvalid input: '<'String, MyObject> map = redissonClient.getMap("simpleMap", new CompositeCodec(StringCodec.INSTANCE, valueCodec, valueCodec)); // or RMapinvalid input: '<'String, String> map = redissonClient.getMap("simpleMap", StringCodec.INSTANCE);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:
- Asynchronous Iterable object
-
entrySetAsync
Returns map entries using iterable. Map entries are loaded in batch. Batch size is defined bycountparam.- Parameters:
count- - size of entries batch- Returns:
- Asynchronous Iterable object
-
fastRemoveAsync
Removes map entries mapped by specifiedkeys.Works faster than
but not returning the value.removeAsync(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
-
fastPutAsync
Stores the specifiedvaluemapped by specifiedkey.Works faster than
but not returning previous value.putAsync(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.
-
fastReplaceAsync
Replaces previous value with a newvaluemapped by specifiedkey.Works faster than
but not returning the previous value.replaceAsync(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.
-
fastPutIfAbsentAsync
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 withputIfAbsentAsync(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.
-
fastPutIfExistsAsync
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 withputIfExistsAsync(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.
-
readAllKeySetAsync
Read all keys at once- Returns:
- keys
-
readAllKeySetAsync
Read all keys mapped by matched keys of this pattern at once- Parameters:
keyPattern- - key Pattern- Returns:
- keys
-
readAllValuesAsync
RFuture<Collection<V>> readAllValuesAsync()Read all values at once- Returns:
- values
-
readAllValuesAsync
Read all values mapped by matched keys of this pattern at once- Parameters:
keyPattern- - key Pattern- Returns:
- values
-
readAllEntrySetAsync
Read all map entries at once- Returns:
- entries
-
readAllEntrySetAsync
Read all entries mapped by matched keys of this pattern at once- Parameters:
keyPattern- - key Pattern- Returns:
- entries
-
readAllMapAsync
Read all map as local instance at once- Returns:
- map
-
getAsync
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.- Parameters:
key- the key- Returns:
- the value mapped by defined
keyornullif value is absent
-
putAsync
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.- Parameters:
key- - map keyvalue- - map value- Returns:
- previous associated value
-
removeAsync
Removes map entry by specifiedkeyand returns value.If
MapWriteris defined thenkeyis deleted in write-through mode.- Parameters:
key- - map key- Returns:
- deleted value,
nullif map entry doesn't exist
-
replaceAsync
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.- Parameters:
key- - map keyvalue- - map value- Returns:
- previous associated value
or
nullif there is no map entry stored before and doesn't store new map entry
-
replaceAsync
Replaces previousoldValuewith anewValuemapped by specifiedkey. Returnsfalseif previous value doesn't exist or equal tooldValue.If
MapWriteris defined thennewValueis written in write-through mode.- Parameters:
key- - map keyoldValue- - map old valuenewValue- - map new value- Returns:
trueif value has been replaced otherwisefalse.
-
removeAsync
Removes map entry only if it exists with specifiedkeyandvalue.If
MapWriteris defined thenkeyis deleted in write-through mode.- Parameters:
key- - map keyvalue- - map value- Returns:
trueif map entry has been removed otherwisefalse.
-
putIfAbsentAsync
Stores the specifiedvaluemapped by specifiedkeyonly if there is no value with specifiedkeystored before.If
MapWriteris defined then new map entry is stored in write-through mode.- 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.
-
putIfExistsAsync
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 is doesn't exists in the hash and value hasn't been set. Previous value if key already exists in the hash and new value has been stored.
-
clearAsync
Clears map without removing options data used during map creation.- Returns:
trueif map was clearedfalseif not
-
addListenerAsync
Adds object event listener- Specified by:
addListenerAsyncin interfaceRObjectAsync- Parameters:
listener- - object event listener- Returns:
- listener id
- See Also:
-