Interface RMapCacheNativeAsync<K,V>

Type Parameters:
K - key
V - value
All Superinterfaces:
RExpirableAsync, RMapAsync<K,V>, RObjectAsync
All Known Subinterfaces:
RMapCacheNative<K,V>
All Known Implementing Classes:
RedissonMapCacheNative

public interface RMapCacheNativeAsync<K,V> extends RMapAsync<K,V>
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

    • putAsync

      RFuture<V> putAsync(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
    • fastPutAsync

      RFuture<Boolean> fastPutAsync(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 putAsync(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.
    • putIfAbsentAsync

      RFuture<V> putIfAbsentAsync(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
    • fastPutIfAbsentAsync

      RFuture<Boolean> fastPutIfAbsentAsync(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 putIfAbsentAsync(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
    • remainTimeToLiveAsync

      RFuture<Long> remainTimeToLiveAsync(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.
    • remainTimeToLiveAsync

      RFuture<Map<K,Long>> remainTimeToLiveAsync(Set<K> keys)
    • putAllAsync

      RFuture<Void> putAllAsync(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.
    • clearExpireAsync

      RFuture<Boolean> clearExpireAsync(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
    • clearExpireAsync

      RFuture<Map<K,Boolean>> clearExpireAsync(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
    • expireEntryAsync

      RFuture<Boolean> expireEntryAsync(K key, Duration ttl)
      Updates time to live and max idle time 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 maxIdleTime and ttl params are equal to 0 then entry stores infinitely.

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

      RFuture<Boolean> expireEntryIfNotSetAsync(K key, Duration ttl)
      Sets time to live and max idle time 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 maxIdleTime and 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.
    • expireEntryIfGreaterAsync

      RFuture<Boolean> expireEntryIfGreaterAsync(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.
    • expireEntryIfLessAsync

      RFuture<Boolean> expireEntryIfLessAsync(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.
    • expireEntriesAsync

      RFuture<Integer> expireEntriesAsync(Set<K> keys, Duration ttl)
      Updates time to live and max idle time 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.
    • expireEntriesIfNotSetAsync

      RFuture<Integer> expireEntriesIfNotSetAsync(Set<K> keys, Duration ttl)
      Sets time to live and max idle time 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.
    • expireEntriesIfGreaterAsync

      RFuture<Integer> expireEntriesIfGreaterAsync(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.
    • expireEntriesIfLessAsync

      RFuture<Integer> expireEntriesIfLessAsync(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.
    • addListenerAsync

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