Interface RMapCacheNativeRx<K,V>

Type Parameters:
K - key
V - value
All Superinterfaces:
RDestroyable, RExpirableRx, RMapRx<K,V>, RObjectRx

public interface RMapCacheNativeRx<K,V> extends RMapRx<K,V>, RDestroyable
Map-based cache with ability to set TTL per entry. Uses Redis native commands for entry expiration and not a scheduled eviction task.

Requires Redis 7.4.0 and higher.

Author:
Nikita Koksharov
  • Method Details

    • put

      io.reactivex.rxjava3.core.Maybe<V> put(K key, V value, Duration ttl)
      Stores value mapped by key with specified time to live. Entry expires after specified time to live.

      If the map previously contained a mapping for the key, the old value is replaced by the specified value.

      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then stores infinitely.
      Returns:
      previous associated value
    • fastPut

      io.reactivex.rxjava3.core.Single<Boolean> fastPut(K key, V value, Duration ttl)
      Stores value mapped by key with specified time to live. Entry expires after specified time to live.

      If the map previously contained a mapping for the key, the old value is replaced by the specified value.

      Works faster than usual put(Object, Object, Duration) as it not returns previous value.

      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then stores infinitely.
      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.
    • putIfAbsent

      io.reactivex.rxjava3.core.Maybe<V> putIfAbsent(K key, V value, Duration ttl)
      If the specified key is not already associated with a value, associate it with the given value.

      Stores value mapped by key with specified time to live. Entry expires after specified time to live.

      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then stores infinitely.
      Returns:
      current associated value
    • fastPutIfAbsent

      io.reactivex.rxjava3.core.Single<Boolean> fastPutIfAbsent(K key, V value, Duration ttl)
      If the specified key is not already associated with a value, associate it with the given value.

      Stores value mapped by key with specified time to live. Entry expires after specified time to live.

      Works faster than usual putIfAbsent(Object, Object, Duration) as it not returns previous value.

      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then stores infinitely.
      Returns:
      true if key is a new key in the hash and value was set. false if key already exists in the hash
    • remainTimeToLive

      io.reactivex.rxjava3.core.Single<Long> remainTimeToLive(K key)
      Remaining time to live of map entry associated with a key.
      Parameters:
      key - map key
      Returns:
      time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
    • remainTimeToLive

      io.reactivex.rxjava3.core.Single<Map<K,Long>> remainTimeToLive(Set<K> keys)
      Remaining time to live of map entries associated with keys.
      Parameters:
      keys - map keys
      Returns:
      Time to live mapped by key. Time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
    • putAll

      io.reactivex.rxjava3.core.Completable putAll(Map<? extends K,? extends V> map, Duration ttl)
      Associates the specified value with the specified key in batch.

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

      Parameters:
      map - - mappings to be stored in this map
      ttl - - time to live for all key\value entries. If 0 then stores infinitely.
    • clearExpire

      io.reactivex.rxjava3.core.Maybe<Boolean> clearExpire(K key)
      Clears an expiration timeout or date of specified entry by key.
      Parameters:
      key - map key
      Returns:
      true if timeout was removed false if entry does not have an associated timeout null if entry does not exist
    • clearExpire

      io.reactivex.rxjava3.core.Single<Map<K,Boolean>> clearExpire(Set<K> keys)
      Clears an expiration timeout or date of specified entries by keys.
      Parameters:
      keys - map keys
      Returns:
      Boolean mapped by key. true if timeout was removed false if entry does not have an associated timeout null if entry does not exist
    • expireEntry

      io.reactivex.rxjava3.core.Single<Boolean> expireEntry(K key, Duration ttl)
      Updates time to live of specified entry by key. Entry expires when specified time to live was reached.

      Returns false if entry already expired or doesn't exist, otherwise returns true.

      Parameters:
      key - map key
      ttl - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.

      if ttl params are equal to 0 then entry stores infinitely.

      Returns:
      returns false if entry already expired or doesn't exist, otherwise returns true.
    • expireEntryIfNotSet

      io.reactivex.rxjava3.core.Single<Boolean> expireEntryIfNotSet(K key, Duration ttl)
      Sets time to live of specified entry by key. If these parameters weren't set before. Entry expires when specified time to live was reached.

      Returns false if entry already has expiration time or doesn't exist, otherwise returns true.

      Parameters:
      key - map key
      ttl - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.

      if ttl params are equal to 0 then entry stores infinitely.

      Returns:
      returns false if entry already has expiration time or doesn't exist, otherwise returns true.
    • expireEntryIfGreater

      io.reactivex.rxjava3.core.Single<Boolean> expireEntryIfGreater(K key, Duration ttl)
      Sets time to live of specified entry by key only if it's greater than timeout set before. Entry expires when specified time to live was reached.

      Returns false if entry already has expiration time or doesn't exist, otherwise returns true.

      Parameters:
      key - map key
      ttl - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.

      if ttl params are equal to 0 then entry stores infinitely.

      Returns:
      returns false if entry already has expiration time or doesn't exist, otherwise returns true.
    • expireEntryIfLess

      io.reactivex.rxjava3.core.Single<Boolean> expireEntryIfLess(K key, Duration ttl)
      Sets time to live of specified entry by key only if it's less than timeout set before. Entry expires when specified time to live was reached.

      Returns false if entry already has expiration time or doesn't exist, otherwise returns true.

      Parameters:
      key - map key
      ttl - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.

      if ttl params are equal to 0 then entry stores infinitely.

      Returns:
      returns false if entry already has expiration time or doesn't exist, otherwise returns true.
    • expireEntries

      io.reactivex.rxjava3.core.Single<Integer> expireEntries(Set<K> keys, Duration ttl)
      Updates time to live of specified entries by keys. Entries expires when specified time to live was reached.

      Returns amount of updated entries.

      Parameters:
      keys - map keys
      ttl - time to live for key\value entries. If 0 then time to live doesn't affect entry expiration.

      if ttl params are equal to 0 then entries are stored infinitely.

      Returns:
      amount of updated entries.
    • expireEntriesIfGreater

      io.reactivex.rxjava3.core.Single<Integer> expireEntriesIfGreater(Set<K> keys, Duration ttl)
      Sets time to live of specified entries by keys only if it's greater than timeout set before. Entries expire when specified time to live was reached.

      Returns amount of updated entries.

      Parameters:
      keys - map keys
      ttl - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.

      if ttl params are equal to 0 then entry stores infinitely.

      Returns:
      amount of updated entries.
    • expireEntriesIfLess

      io.reactivex.rxjava3.core.Single<Integer> expireEntriesIfLess(Set<K> keys, Duration ttl)
      Sets time to live of specified entries by keys only if it's less than timeout set before. Entries expire when specified time to live was reached.

      Returns amount of updated entries.

      Parameters:
      keys - map keys
      ttl - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.

      if ttl params are equal to 0 then entry stores infinitely.

      Returns:
      amount of updated entries.
    • expireEntriesIfNotSet

      io.reactivex.rxjava3.core.Single<Integer> expireEntriesIfNotSet(Set<K> keys, Duration ttl)
      Sets time to live of specified entries by keys. If these parameters weren't set before. Entries expire when specified time to live was reached.

      Returns amount of updated entries.

      Parameters:
      keys - map keys
      ttl - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.

      if ttl params are equal to 0 then entry stores infinitely.

      Returns:
      amount of updated entries.
    • addListener

      io.reactivex.rxjava3.core.Single<Integer> addListener(ObjectListener listener)
      Adds object event listener
      Specified by:
      addListener in interface RMapRx<K,V>
      Specified by:
      addListener in interface RObjectRx
      Parameters:
      listener - object event listener
      Returns:
      listener id
      See Also: