Interface RMapAsync<K,V>

Type Parameters:
K - key
V - value
All Superinterfaces:
RExpirableAsync, RObjectAsync
All Known Subinterfaces:
RLocalCachedMap<K,V>, RMap<K,V>, RMapCache<K,V>, RMapCacheAsync<K,V>
All Known Implementing Classes:
RedissonLocalCachedMap, RedissonMap, RedissonMapCache, RedissonTransactionalLocalCachedMap, RedissonTransactionalMap, RedissonTransactionalMapCache

public interface RMapAsync<K,V> extends RExpirableAsync
Async interface for Redis based implementation of 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 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 is null.
      Parameters:
      key - - map key
      value - - value to be merged with the existing value associated with the key or to be associated with the key, if no existing value
      remappingFunction - - the function is invoked with the existing value to compute new value
      Returns:
      new value associated with the specified key or null if no value associated with the key
    • computeAsync

      RFuture<V> computeAsync(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
      Computes a new mapping for the specified key and its current mapped value.
      Parameters:
      key - - map key
      remappingFunction - - function to compute a value
      Returns:
      the new value associated with the specified key, or null if none
    • computeIfAbsentAsync

      RFuture<V> computeIfAbsentAsync(K key, Function<? super K,? extends V> mappingFunction)
      Computes a mapping for the specified key if it's not mapped before.
      Parameters:
      key - - map key
      mappingFunction - - function to compute a value
      Returns:
      current or new computed value associated with the specified key, or null if 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 key
      remappingFunction - - function to compute a value
      Returns:
      the new value associated with the specified key, or null if none
    • loadAllAsync

      RFuture<Void> loadAllAsync(boolean replaceExistingValues, int parallelism)
      Loads all map entries to this Redis map using MapLoader.
      Parameters:
      replaceExistingValues - - true if existed values should be replaced, false otherwise.
      parallelism - - parallelism level, used to increase speed of process execution
      Returns:
      void
    • loadAllAsync

      RFuture<Void> loadAllAsync(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
      Loads map entries using MapLoader whose keys are listed in defined keys parameter.
      Parameters:
      keys - - map keys
      replaceExistingValues - - true if existed values should be replaced, false otherwise.
      parallelism - - parallelism level, used to increase speed of process execution
      Returns:
      void
    • valueSizeAsync

      RFuture<Integer> valueSizeAsync(K key)
      Returns size of value mapped by key in bytes
      Parameters:
      key - - map key
      Returns:
      size of value
    • getAllAsync

      RFuture<Map<K,V>> getAllAsync(Set<K> keys)
      Returns map slice contained the mappings with defined 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.

      Parameters:
      keys - - map keys
      Returns:
      Map slice
    • putAllAsync

      RFuture<Void> putAllAsync(Map<? extends K,? extends V> map)
      Stores map entries specified in map object in batch mode.

      If MapWriter is defined then map entries will be stored in write-through mode.

      Parameters:
      map - mappings to be stored in this map
      Returns:
      void
    • putAllAsync

      RFuture<Void> putAllAsync(Map<? extends K,? extends V> map, int batchSize)
      Stores map entries specified in 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.

      Parameters:
      map - mappings to be stored in this map
      batchSize - - size of map entries batch
      Returns:
      void
    • randomKeysAsync

      RFuture<Set<K>> randomKeysAsync(int count)
      Returns random keys from this map limited by count
      Parameters:
      count - - keys amount to return
      Returns:
      random keys
    • randomEntriesAsync

      RFuture<Map<K,V>> randomEntriesAsync(int count)
      Returns random map entries from this map limited by count
      Parameters:
      count - - entries amount to return
      Returns:
      random entries
    • addAndGetAsync

      RFuture<V> addAndGetAsync(K key, Number delta)
      Adds the given delta to the current value by mapped key.

      Works only with codecs below

      JsonJacksonCodec,

      StringCodec,

      IntegerCodec,

      DoubleCodec

      LongCodec

      Parameters:
      key - - map key
      delta - the value to add
      Returns:
      the updated value
    • containsValueAsync

      RFuture<Boolean> containsValueAsync(Object value)
      Returns true if this map contains any map entry with specified value, otherwise false
      Parameters:
      value - - map value
      Returns:
      true if this map contains any map entry with specified value, otherwise false
    • containsKeyAsync

      RFuture<Boolean> containsKeyAsync(Object key)
      Returns true if this map contains map entry mapped by specified key, otherwise false
      Parameters:
      key - - map key
      Returns:
      true if this map contains map entry mapped by specified key, otherwise false
    • sizeAsync

      RFuture<Integer> sizeAsync()
      Returns size of this map
      Returns:
      size
    • fastRemoveAsync

      RFuture<Long> fastRemoveAsync(K... keys)
      Removes map entries mapped by specified keys.

      Works faster than removeAsync(Object) but not returning the value.

      If MapWriter is defined then keysare 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

      RFuture<Boolean> fastPutAsync(K key, V value)
      Stores the specified value mapped by specified key.

      Works faster than putAsync(Object, Object) but not returning previous value.

      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.

      Parameters:
      key - - map key
      value - - 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.
    • fastReplaceAsync

      RFuture<Boolean> fastReplaceAsync(K key, V value)
      Replaces previous value with a new value mapped by specified key.

      Works faster than replaceAsync(Object, Object) but not returning the previous value.

      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.

      Parameters:
      key - - map key
      value - - map value
      Returns:
      true if key exists and value was updated. false if key doesn't exists and value wasn't updated.
    • fastPutIfAbsentAsync

      RFuture<Boolean> fastPutIfAbsentAsync(K key, V value)
      Stores the specified 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 putIfAbsentAsync(Object, Object) but not returning the previous value associated with key

      If MapWriter is defined then new map entry is stored in write-through mode.

      Parameters:
      key - - map key
      value - - 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.
    • fastPutIfExistsAsync

      RFuture<Boolean> fastPutIfExistsAsync(K key, V value)
      Stores the specified 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 putIfExistsAsync(Object, Object) but doesn't return previous value associated with key

      If MapWriter is defined then new map entry is stored in write-through mode.

      Parameters:
      key - - map key
      value - - 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.
    • readAllKeySetAsync

      RFuture<Set<K>> readAllKeySetAsync()
      Read all keys at once
      Returns:
      keys
    • readAllValuesAsync

      RFuture<Collection<V>> readAllValuesAsync()
      Read all values at once
      Returns:
      values
    • readAllEntrySetAsync

      RFuture<Set<Map.Entry<K,V>>> readAllEntrySetAsync()
      Read all map entries at once
      Returns:
      entries
    • readAllMapAsync

      RFuture<Map<K,V>> readAllMapAsync()
      Read all map as local instance at once
      Returns:
      map
    • getAsync

      RFuture<V> getAsync(K key)
      Returns the value mapped by defined 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.

      Parameters:
      key - the key
      Returns:
      the value mapped by defined key or null if value is absent
    • putAsync

      RFuture<V> putAsync(K key, V value)
      Stores the specified 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.

      Parameters:
      key - - map key
      value - - map value
      Returns:
      previous associated value
    • removeAsync

      RFuture<V> removeAsync(K key)
      Removes map entry by specified key and returns value.

      If MapWriter is defined then keyis deleted in write-through mode.

      Parameters:
      key - - map key
      Returns:
      deleted value, null if map entry doesn't exist
    • replaceAsync

      RFuture<V> replaceAsync(K key, V value)
      Replaces previous value with a new 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 valueis written in write-through mode.

      Parameters:
      key - - map key
      value - - map value
      Returns:
      previous associated value or null if there is no map entry stored before and doesn't store new map entry
    • replaceAsync

      RFuture<Boolean> replaceAsync(K key, V oldValue, V newValue)
      Replaces previous 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 newValueis written in write-through mode.

      Parameters:
      key - - map key
      oldValue - - map old value
      newValue - - map new value
      Returns:
      true if value has been replaced otherwise false.
    • removeAsync

      RFuture<Boolean> removeAsync(Object key, Object value)
      Removes map entry only if it exists with specified key and value.

      If MapWriter is defined then keyis deleted in write-through mode.

      Parameters:
      key - - map key
      value - - map value
      Returns:
      true if map entry has been removed otherwise false.
    • putIfAbsentAsync

      RFuture<V> putIfAbsentAsync(K key, V value)
      Stores the specified value mapped by specified 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.

      Parameters:
      key - - map key
      value - - 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.
    • putIfExistsAsync

      RFuture<V> putIfExistsAsync(K key, V value)
      Stores the specified value mapped by key only if mapping already exists.

      If MapWriter is defined then new map entry is stored in write-through mode.

      Parameters:
      key - - map key
      value - - map value
      Returns:
      null if 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

      RFuture<Boolean> clearAsync()
      Clears map without removing options data used during map creation.
      Returns:
      true if map was cleared false if not
    • addListenerAsync

      RFuture<Integer> addListenerAsync(ObjectListener listener)
      Adds object event listener
      Specified by:
      addListenerAsync in interface RObjectAsync
      Parameters:
      listener - - object event listener
      Returns:
      listener id
      See Also: