Interface RMapRx<K,V>

Type Parameters:
K - key
V - value
All Superinterfaces:
RExpirableRx, RObjectRx
All Known Subinterfaces:
RMapCacheRx<K,V>

public interface RMapRx<K,V> extends RExpirableRx
RxJava2 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 Summary

    Modifier and Type
    Method
    Description
    io.reactivex.rxjava3.core.Single<V>
    addAndGet(K key, Number delta)
    Adds the given delta to the current value by mapped key.
    io.reactivex.rxjava3.core.Maybe<V>
    compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
    Computes a new mapping for the specified key and its current mapped value.
    io.reactivex.rxjava3.core.Maybe<V>
    computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
    Computes a mapping for the specified key if it's not mapped before.
    io.reactivex.rxjava3.core.Maybe<V>
    computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
    Computes a mapping for the specified key only if it's already mapped.
    io.reactivex.rxjava3.core.Single<Boolean>
    Returns true if this map contains map entry mapped by specified key, otherwise false
    io.reactivex.rxjava3.core.Single<Boolean>
    Returns true if this map contains any map entry with specified value, otherwise false
    io.reactivex.rxjava3.core.Flowable<Map.Entry<K,V>>
    Returns iterator over map entries collection.
    io.reactivex.rxjava3.core.Flowable<Map.Entry<K,V>>
    entryIterator(int count)
    Returns iterator over map entries collection.
    io.reactivex.rxjava3.core.Flowable<Map.Entry<K,V>>
    Returns iterator over map entries collection.
    io.reactivex.rxjava3.core.Flowable<Map.Entry<K,V>>
    entryIterator(String pattern, int count)
    Returns iterator over map entries collection.
    io.reactivex.rxjava3.core.Single<Boolean>
    fastPut(K key, V value)
    Stores the specified value mapped by specified key.
    io.reactivex.rxjava3.core.Single<Boolean>
    fastPutIfAbsent(K key, V value)
    Stores the specified value mapped by specified key only if there is no value with specifiedkey stored before.
    io.reactivex.rxjava3.core.Single<Boolean>
    fastPutIfExists(K key, V value)
    Stores the specified value mapped by key only if mapping already exists.
    io.reactivex.rxjava3.core.Single<Long>
    fastRemove(K... keys)
    Removes map entries mapped by specified keys.
    io.reactivex.rxjava3.core.Maybe<V>
    get(K key)
    Returns the value mapped by defined key or null if value is absent.
    io.reactivex.rxjava3.core.Single<Map<K,V>>
    getAll(Set<K> keys)
    Returns map slice contained the mappings with defined keys.
    Returns RLock instance associated with key
    getLock(K key)
    Returns RLock instance associated with key
    Returns RPermitExpirableSemaphore instance associated with key
    Returns RReadWriteLock instance associated with key
    Returns RSemaphore instance associated with key
    io.reactivex.rxjava3.core.Flowable<K>
    Returns iterator over key set of this map.
    io.reactivex.rxjava3.core.Flowable<K>
    keyIterator(int count)
    Returns iterator over key set of this map.
    io.reactivex.rxjava3.core.Flowable<K>
    Returns iterator over key set of this map.
    io.reactivex.rxjava3.core.Flowable<K>
    keyIterator(String pattern, int count)
    Returns iterator over key set of this map.
    io.reactivex.rxjava3.core.Completable
    loadAll(boolean replaceExistingValues, int parallelism)
    Loads all map entries to this Redis map using MapLoader.
    io.reactivex.rxjava3.core.Completable
    loadAll(Set<? extends K> keys, boolean replaceExistingValues, int parallelism)
    Loads map entries using MapLoader whose keys are listed in defined keys parameter.
    io.reactivex.rxjava3.core.Maybe<V>
    merge(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.
    io.reactivex.rxjava3.core.Maybe<V>
    put(K key, V value)
    Stores the specified value mapped by specified key.
    io.reactivex.rxjava3.core.Completable
    putAll(Map<? extends K,? extends V> map)
    Stores map entries specified in map object in batch mode.
    io.reactivex.rxjava3.core.Maybe<V>
    putIfAbsent(K key, V value)
    Stores the specified value mapped by specified key only if there is no value with specifiedkey stored before.
    io.reactivex.rxjava3.core.Maybe<V>
    putIfExists(K key, V value)
    Stores the specified value mapped by key only if mapping already exists.
    io.reactivex.rxjava3.core.Single<Map<K,V>>
    randomEntries(int count)
    Returns random map entries from this map limited by count
    io.reactivex.rxjava3.core.Single<Set<K>>
    randomKeys(int count)
    Returns random keys from this map limited by count
    io.reactivex.rxjava3.core.Single<Set<Map.Entry<K,V>>>
    Read all map entries at once
    io.reactivex.rxjava3.core.Single<Set<K>>
    Read all keys at once
    io.reactivex.rxjava3.core.Single<Map<K,V>>
    Read all map as local instance at once
    io.reactivex.rxjava3.core.Single<Collection<V>>
    Read all values at once
    io.reactivex.rxjava3.core.Single<Boolean>
    remove(Object key, Object value)
    Removes map entry only if it exists with specified key and value.
    io.reactivex.rxjava3.core.Maybe<V>
    remove(K key)
    Removes map entry by specified key and returns value.
    io.reactivex.rxjava3.core.Maybe<V>
    replace(K key, V value)
    Replaces previous value with a new value mapped by specified key.
    io.reactivex.rxjava3.core.Single<Boolean>
    replace(K key, V oldValue, V newValue)
    Replaces previous oldValue with a newValue mapped by specified key.
    io.reactivex.rxjava3.core.Single<Integer>
    Returns size of this map
    io.reactivex.rxjava3.core.Flowable<V>
    Returns iterator over values collection of this map.
    io.reactivex.rxjava3.core.Flowable<V>
    valueIterator(int count)
    Returns iterator over values collection of this map.
    io.reactivex.rxjava3.core.Flowable<V>
    Returns iterator over values collection of this map.
    io.reactivex.rxjava3.core.Flowable<V>
    valueIterator(String pattern, int count)
    Returns iterator over values collection of this map.
    io.reactivex.rxjava3.core.Single<Integer>
    valueSize(K key)
    Returns size of value mapped by key in bytes
  • Method Details

    • merge

      io.reactivex.rxjava3.core.Maybe<V> merge(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
    • compute

      io.reactivex.rxjava3.core.Maybe<V> compute(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
    • computeIfAbsent

      io.reactivex.rxjava3.core.Maybe<V> computeIfAbsent(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
    • computeIfPresent

      io.reactivex.rxjava3.core.Maybe<V> computeIfPresent(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
    • loadAll

      io.reactivex.rxjava3.core.Completable loadAll(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
    • loadAll

      io.reactivex.rxjava3.core.Completable loadAll(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
    • valueSize

      io.reactivex.rxjava3.core.Single<Integer> valueSize(K key)
      Returns size of value mapped by key in bytes
      Parameters:
      key - - map key
      Returns:
      size of value
    • getAll

      io.reactivex.rxjava3.core.Single<Map<K,V>> getAll(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
    • putAll

      io.reactivex.rxjava3.core.Completable putAll(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
    • addAndGet

      io.reactivex.rxjava3.core.Single<V> addAndGet(K key, Number delta)
      Adds the given delta to the current value by mapped key. Works only for numeric values!
      Parameters:
      key - - map key
      delta - the value to add
      Returns:
      the updated value
    • containsValue

      io.reactivex.rxjava3.core.Single<Boolean> containsValue(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
    • containsKey

      io.reactivex.rxjava3.core.Single<Boolean> containsKey(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
    • size

      io.reactivex.rxjava3.core.Single<Integer> size()
      Returns size of this map
      Returns:
      size
    • fastRemove

      io.reactivex.rxjava3.core.Single<Long> fastRemove(K... keys)
      Removes map entries mapped by specified keys.

      Works faster than remove(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
    • fastPut

      io.reactivex.rxjava3.core.Single<Boolean> fastPut(K key, V value)
      Stores the specified value mapped by specified key.

      Works faster than put(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.
    • fastPutIfAbsent

      io.reactivex.rxjava3.core.Single<Boolean> fastPutIfAbsent(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 putIfAbsent(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.
    • readAllKeySet

      io.reactivex.rxjava3.core.Single<Set<K>> readAllKeySet()
      Read all keys at once
      Returns:
      keys
    • readAllValues

      io.reactivex.rxjava3.core.Single<Collection<V>> readAllValues()
      Read all values at once
      Returns:
      values
    • readAllEntrySet

      io.reactivex.rxjava3.core.Single<Set<Map.Entry<K,V>>> readAllEntrySet()
      Read all map entries at once
      Returns:
      entries
    • readAllMap

      io.reactivex.rxjava3.core.Single<Map<K,V>> readAllMap()
      Read all map as local instance at once
      Returns:
      map
    • get

      io.reactivex.rxjava3.core.Maybe<V> get(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
    • put

      io.reactivex.rxjava3.core.Maybe<V> put(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
    • remove

      io.reactivex.rxjava3.core.Maybe<V> remove(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
    • replace

      io.reactivex.rxjava3.core.Maybe<V> replace(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
    • replace

      io.reactivex.rxjava3.core.Single<Boolean> replace(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.
    • remove

      io.reactivex.rxjava3.core.Single<Boolean> remove(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.
    • putIfAbsent

      io.reactivex.rxjava3.core.Maybe<V> putIfAbsent(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.
    • putIfExists

      io.reactivex.rxjava3.core.Maybe<V> putIfExists(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 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

      io.reactivex.rxjava3.core.Single<Set<K>> randomKeys(int count)
      Returns random keys from this map limited by count
      Parameters:
      count - - keys amount to return
      Returns:
      random keys
    • randomEntries

      io.reactivex.rxjava3.core.Single<Map<K,V>> randomEntries(int count)
      Returns random map entries from this map limited by count
      Parameters:
      count - - entries amount to return
      Returns:
      random entries
    • fastPutIfExists

      io.reactivex.rxjava3.core.Single<Boolean> fastPutIfExists(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 putIfExists(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.
    • entryIterator

      io.reactivex.rxjava3.core.Flowable<Map.Entry<K,V>> entryIterator()
      Returns iterator over map entries collection. Map entries are loaded in batch. Batch size is 10.
      Returns:
      iterator
      See Also:
    • entryIterator

      io.reactivex.rxjava3.core.Flowable<Map.Entry<K,V>> entryIterator(int count)
      Returns iterator over map entries collection. Map entries are loaded in batch. Batch size is defined by count param.
      Parameters:
      count - - size of entries batch
      Returns:
      iterator
      See Also:
    • entryIterator

      io.reactivex.rxjava3.core.Flowable<Map.Entry<K,V>> entryIterator(String pattern)
      Returns iterator over map entries collection. Map entries are loaded in batch. Batch size is 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

      Parameters:
      pattern - - key pattern
      Returns:
      iterator
      See Also:
    • entryIterator

      io.reactivex.rxjava3.core.Flowable<Map.Entry<K,V>> entryIterator(String pattern, int count)
      Returns iterator over map entries collection. Map entries are loaded in batch. Batch size is defined by 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

      Parameters:
      pattern - - key pattern
      count - - size of entries batch
      Returns:
      iterator
      See Also:
    • valueIterator

      io.reactivex.rxjava3.core.Flowable<V> valueIterator()
      Returns iterator over values collection of this map. Values are loaded in batch. Batch size is 10.
      Returns:
      iterator
      See Also:
    • valueIterator

      io.reactivex.rxjava3.core.Flowable<V> valueIterator(int count)
      Returns iterator over values collection of this map. Values are loaded in batch. Batch size is defined by count param.
      Parameters:
      count - - size of values batch
      Returns:
      iterator
      See Also:
    • valueIterator

      io.reactivex.rxjava3.core.Flowable<V> valueIterator(String pattern)
      Returns iterator over values collection of this map. Values are loaded in batch. Batch size is 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

      Parameters:
      pattern - - key pattern
      Returns:
      iterator
      See Also:
    • valueIterator

      io.reactivex.rxjava3.core.Flowable<V> valueIterator(String pattern, int count)
      Returns iterator over values collection of this map. Values are loaded in batch. Batch size is defined by 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

      Parameters:
      pattern - - key pattern
      count - - size of values batch
      Returns:
      iterator
      See Also:
    • keyIterator

      io.reactivex.rxjava3.core.Flowable<K> keyIterator()
      Returns iterator over key set of this map. Keys are loaded in batch. Batch size is 10.
      Returns:
      iterator
      See Also:
    • keyIterator

      io.reactivex.rxjava3.core.Flowable<K> keyIterator(int count)
      Returns iterator over key set of this map. Keys are loaded in batch. Batch size is defined by count param.
      Parameters:
      count - - size of keys batch
      Returns:
      iterator
      See Also:
    • keyIterator

      io.reactivex.rxjava3.core.Flowable<K> keyIterator(String pattern)
      Returns iterator over key set of this map. If 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

      Parameters:
      pattern - - key pattern
      Returns:
      iterator
      See Also:
    • keyIterator

      io.reactivex.rxjava3.core.Flowable<K> keyIterator(String pattern, int count)
      Returns iterator over key set of this map. If 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

      Parameters:
      pattern - - key pattern
      count - - size of keys batch
      Returns:
      iterator
      See Also:
    • getPermitExpirableSemaphore

      RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(K key)
      Returns RPermitExpirableSemaphore instance associated with key
      Parameters:
      key - - map key
      Returns:
      permitExpirableSemaphore
    • getSemaphore

      RSemaphoreRx getSemaphore(K key)
      Returns RSemaphore instance associated with key
      Parameters:
      key - - map key
      Returns:
      semaphore
    • getFairLock

      RLockRx getFairLock(K key)
      Returns RLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      fairLock
    • getReadWriteLock

      RReadWriteLockRx getReadWriteLock(K key)
      Returns RReadWriteLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      readWriteLock
    • getLock

      RLockRx getLock(K key)
      Returns RLock instance associated with key
      Parameters:
      key - - map key
      Returns:
      lock