Package org.redisson

Class RedissonMapCacheNative<K,V>

java.lang.Object
org.redisson.RedissonObject
org.redisson.RedissonMap<K,V>
org.redisson.RedissonMapCacheNative<K,V>
Type Parameters:
K - key
V - value
All Implemented Interfaces:
ConcurrentMap<K,V>, Map<K,V>, RDestroyable, RExpirable, RExpirableAsync, RMap<K,V>, RMapAsync<K,V>, RMapCacheNative<K,V>, RMapCacheNativeAsync<K,V>, RObject, RObjectAsync

public class RedissonMapCacheNative<K,V> extends RedissonMap<K,V> implements RMapCacheNative<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.
Author:
Nikita Koksharov
  • Constructor Details

  • Method Details

    • put

      public V put(K key, V value, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      put in interface RMapCacheNative<K,V>
      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then stores infinitely.
      Returns:
      previous associated value
    • putAsync

      public RFuture<V> putAsync(K key, V value, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      putAsync in interface RMapCacheNativeAsync<K,V>
      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then stores infinitely.
      Returns:
      previous associated value
    • putOperationAsync

      protected RFuture<V> putOperationAsync(K key, V value, Duration ttl)
    • fastPut

      public boolean fastPut(K key, V value, Duration ttl)
      Description copied from interface: RMapCacheNative
      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 RMapCacheNative.put(Object, Object, Duration) as it not returns previous value.

      Specified by:
      fastPut in interface RMapCacheNative<K,V>
      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.
    • fastPutAsync

      public RFuture<Boolean> fastPutAsync(K key, V value, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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 RMapCacheNativeAsync.putAsync(Object, Object, Duration) as it not returns previous value.

      Specified by:
      fastPutAsync in interface RMapCacheNativeAsync<K,V>
      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.
    • fastPutOperationAsync

      protected RFuture<Boolean> fastPutOperationAsync(K key, V value, Duration ttl)
    • putIfAbsent

      public V putIfAbsent(K key, V value, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      putIfAbsent in interface RMapCacheNative<K,V>
      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then stores infinitely.
      Returns:
      current associated value
    • putIfAbsentAsync

      public RFuture<V> putIfAbsentAsync(K key, V value, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      putIfAbsentAsync in interface RMapCacheNativeAsync<K,V>
      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then stores infinitely.
      Returns:
      current associated value
    • putIfAbsentOperationAsync

      protected RFuture<V> putIfAbsentOperationAsync(K key, V value, Duration ttl)
    • fastPutIfAbsent

      public boolean fastPutIfAbsent(K key, V value, Duration ttl)
      Description copied from interface: RMapCacheNative
      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 RMapCacheNative.putIfAbsent(Object, Object, Duration) as it not returns previous value.

      Specified by:
      fastPutIfAbsent in interface RMapCacheNative<K,V>
      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
    • fastPutIfAbsentAsync

      public RFuture<Boolean> fastPutIfAbsentAsync(K key, V value, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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 RMapCacheNativeAsync.putIfAbsentAsync(Object, Object, Duration) as it not returns previous value.

      Specified by:
      fastPutIfAbsentAsync in interface RMapCacheNativeAsync<K,V>
      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
    • fastPutIfAbsentOperationAsync

      protected RFuture<Boolean> fastPutIfAbsentOperationAsync(K key, V value, Duration ttl)
    • remainTimeToLive

      public long remainTimeToLive(K key)
      Description copied from interface: RMapCacheNative
      Remaining time to live of map entry associated with a key.
      Specified by:
      remainTimeToLive in interface RMapCacheNative<K,V>
      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

      public RFuture<Long> remainTimeToLiveAsync(K key)
      Description copied from interface: RMapCacheNativeAsync
      Remaining time to live of map entry associated with a key.
      Specified by:
      remainTimeToLiveAsync in interface RMapCacheNativeAsync<K,V>
      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.
    • putAll

      public void putAll(Map<? extends K,? extends V> map, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      putAll in interface RMapCacheNative<K,V>
      Parameters:
      map - - mappings to be stored in this map
      ttl - - time to live for all key\value entries. If 0 then stores infinitely.
    • putAllAsync

      public RFuture<Void> putAllAsync(Map<? extends K,? extends V> map, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      putAllAsync in interface RMapCacheNativeAsync<K,V>
      Parameters:
      map - - mappings to be stored in this map
      ttl - - time to live for all key\value entries. If 0 then stores infinitely.
    • putAllOperationAsync

      protected RFuture<Void> putAllOperationAsync(Map<? extends K,? extends V> map, Duration ttl)
    • expireEntry

      public boolean expireEntry(K key, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      expireEntry in interface RMapCacheNative<K,V>
      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.
    • expireEntryAsync

      public RFuture<Boolean> expireEntryAsync(K key, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      expireEntryAsync in interface RMapCacheNativeAsync<K,V>
      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.
    • expireEntryIfNotSet

      public boolean expireEntryIfNotSet(K key, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      expireEntryIfNotSet in interface RMapCacheNative<K,V>
      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.
    • expireEntryIfNotSetAsync

      public RFuture<Boolean> expireEntryIfNotSetAsync(K key, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      expireEntryIfNotSetAsync in interface RMapCacheNativeAsync<K,V>
      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.
    • expireEntries

      public int expireEntries(Set<K> keys, Duration ttl)
      Description copied from interface: RMapCacheNative
      Updates time to live of specified entries by keys. Entries expires when specified time to live was reached.

      Returns amount of updated entries.

      Specified by:
      expireEntries in interface RMapCacheNative<K,V>
      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.
    • expireEntriesAsync

      public RFuture<Integer> expireEntriesAsync(Set<K> keys, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      expireEntriesAsync in interface RMapCacheNativeAsync<K,V>
      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.
    • expireEntriesIfNotSet

      public int expireEntriesIfNotSet(Set<K> keys, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      expireEntriesIfNotSet in interface RMapCacheNative<K,V>
      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.
    • expireEntriesIfNotSetAsync

      public RFuture<Integer> expireEntriesIfNotSetAsync(Set<K> keys, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      expireEntriesIfNotSetAsync in interface RMapCacheNativeAsync<K,V>
      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.
    • expireEntryIfGreater

      public boolean expireEntryIfGreater(K key, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      expireEntryIfGreater in interface RMapCacheNative<K,V>
      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

      public boolean expireEntryIfLess(K key, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      expireEntryIfLess in interface RMapCacheNative<K,V>
      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.
    • expireEntriesIfGreater

      public int expireEntriesIfGreater(Set<K> keys, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      expireEntriesIfGreater in interface RMapCacheNative<K,V>
      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

      public int expireEntriesIfLess(Set<K> keys, Duration ttl)
      Description copied from interface: RMapCacheNative
      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.

      Specified by:
      expireEntriesIfLess in interface RMapCacheNative<K,V>
      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.
    • expireEntryIfGreaterAsync

      public RFuture<Boolean> expireEntryIfGreaterAsync(K key, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      expireEntryIfGreaterAsync in interface RMapCacheNativeAsync<K,V>
      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

      public RFuture<Boolean> expireEntryIfLessAsync(K key, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      expireEntryIfLessAsync in interface RMapCacheNativeAsync<K,V>
      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.
    • expireEntriesIfGreaterAsync

      public RFuture<Integer> expireEntriesIfGreaterAsync(Set<K> keys, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      expireEntriesIfGreaterAsync in interface RMapCacheNativeAsync<K,V>
      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

      public RFuture<Integer> expireEntriesIfLessAsync(Set<K> keys, Duration ttl)
      Description copied from interface: RMapCacheNativeAsync
      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.

      Specified by:
      expireEntriesIfLessAsync in interface RMapCacheNativeAsync<K,V>
      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.
    • clearExpire

      public boolean clearExpire(K key)
      Description copied from interface: RMapCacheNative
      Clear an expire timeout or expire date of specified entry by key.
      Specified by:
      clearExpire in interface RMapCacheNative<K,V>
      Parameters:
      key - map key
      Returns:
      true if timeout was removed false if object does not exist or does not have an associated timeout
    • clearExpireAsync

      public RFuture<Boolean> clearExpireAsync(K key)
      Description copied from interface: RMapCacheNativeAsync
      Clear an expire timeout or expire date of specified entry by key.
      Specified by:
      clearExpireAsync in interface RMapCacheNativeAsync<K,V>
      Parameters:
      key - map key
      Returns:
      true if timeout was removed false if object does not exist or does not have an associated timeout
    • addListener

      public int addListener(ObjectListener listener)
      Description copied from interface: RObject
      Adds object event listener
      Specified by:
      addListener in interface RMap<K,V>
      Specified by:
      addListener in interface RMapCacheNative<K,V>
      Specified by:
      addListener in interface RObject
      Overrides:
      addListener in class RedissonMap<K,V>
      Parameters:
      listener - - object event listener
      Returns:
      listener id
      See Also:
    • addListenerAsync

      public RFuture<Integer> addListenerAsync(ObjectListener listener)
      Description copied from interface: RObjectAsync
      Adds object event listener
      Specified by:
      addListenerAsync in interface RMapAsync<K,V>
      Specified by:
      addListenerAsync in interface RMapCacheNativeAsync<K,V>
      Specified by:
      addListenerAsync in interface RObjectAsync
      Overrides:
      addListenerAsync in class RedissonMap<K,V>
      Parameters:
      listener - - object event listener
      Returns:
      listener id
      See Also:
    • removeListener

      public void removeListener(int listenerId)
      Description copied from interface: RObject
      Removes object event listener
      Specified by:
      removeListener in interface RObject
      Overrides:
      removeListener in class RedissonMap<K,V>
      Parameters:
      listenerId - - listener id
    • removeListenerAsync

      public RFuture<Void> removeListenerAsync(int listenerId)
      Description copied from interface: RObjectAsync
      Removes object event listener
      Specified by:
      removeListenerAsync in interface RObjectAsync
      Overrides:
      removeListenerAsync in class RedissonMap<K,V>
      Parameters:
      listenerId - - listener id
    • expire

      public boolean expire(long timeToLive, TimeUnit timeUnit)
      Description copied from interface: RExpirable
      Specified by:
      expire in interface RExpirable
      Parameters:
      timeToLive - - timeout before object will be deleted
      timeUnit - - timeout time unit
      Returns:
      true if the timeout was set and false if not
    • expireAsync

      public RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAsync in interface RExpirableAsync
      Parameters:
      timeToLive - - timeout before object will be deleted
      timeUnit - - timeout time unit
      Returns:
      true if the timeout was set and false if not
    • expireAt

      public boolean expireAt(long timestamp)
      Description copied from interface: RExpirable
      Specified by:
      expireAt in interface RExpirable
      Parameters:
      timestamp - - expire date in milliseconds (Unix timestamp)
      Returns:
      true if the timeout was set and false if not
    • expireAtAsync

      public RFuture<Boolean> expireAtAsync(long timestamp)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAtAsync in interface RExpirableAsync
      Parameters:
      timestamp - - expire date in milliseconds (Unix timestamp)
      Returns:
      true if the timeout was set and false if not
    • expire

      public boolean expire(Instant instant)
      Description copied from interface: RExpirable
      Sets an expiration date for this object. When expire date comes the key will automatically be deleted.
      Specified by:
      expire in interface RExpirable
      Parameters:
      instant - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfSet

      public boolean expireIfSet(Instant time)
      Description copied from interface: RExpirable
      Sets an expiration date for this object only if it has been already set. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfSet in interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfSetAsync

      public RFuture<Boolean> expireIfSetAsync(Instant time)
      Description copied from interface: RExpirableAsync
      Sets an expiration date for this object only if it has been already set. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfSetAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSet

      public boolean expireIfNotSet(Instant time)
      Description copied from interface: RExpirable
      Sets an expiration date for this object only if it hasn't been set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfNotSet in interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSetAsync

      public RFuture<Boolean> expireIfNotSetAsync(Instant time)
      Description copied from interface: RExpirableAsync
      Sets an expiration date for this object only if it hasn't been set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfNotSetAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfGreater

      public boolean expireIfGreater(Instant time)
      Description copied from interface: RExpirable
      Sets an expiration date for this object only if it's greater than expiration date set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfGreater in interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfGreaterAsync

      public RFuture<Boolean> expireIfGreaterAsync(Instant time)
      Description copied from interface: RExpirableAsync
      Sets an expiration date for this object only if it's greater than expiration date set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfGreaterAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfLess

      public boolean expireIfLess(Instant time)
      Description copied from interface: RExpirable
      Sets an expiration date for this object only if it's less than expiration date set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfLess in interface RExpirable
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfLessAsync

      public RFuture<Boolean> expireIfLessAsync(Instant time)
      Description copied from interface: RExpirableAsync
      Sets an expiration date for this object only if it's less than expiration date set before. When expire date comes the object will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfLessAsync in interface RExpirableAsync
      Parameters:
      time - expire date
      Returns:
      true if the timeout was set and false if not
    • expireAsync

      public RFuture<Boolean> expireAsync(Instant instant)
      Description copied from interface: RExpirableAsync
      Set an expire date for object. When expire date comes the key will automatically be deleted.
      Specified by:
      expireAsync in interface RExpirableAsync
      Parameters:
      instant - - expire date
      Returns:
      true if the timeout was set and false if not
    • expire

      public boolean expire(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object. After the timeout has expired, the key will automatically be deleted.
      Specified by:
      expire in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireAsync

      public RFuture<Boolean> expireAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Set a timeout for object. After the timeout has expired, the key will automatically be deleted.
      Specified by:
      expireAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireAt

      public boolean expireAt(Date timestamp)
      Description copied from interface: RExpirable
      Specified by:
      expireAt in interface RExpirable
      Parameters:
      timestamp - - expire date
      Returns:
      true if the timeout was set and false if not
    • expireAtAsync

      public RFuture<Boolean> expireAtAsync(Date timestamp)
      Description copied from interface: RExpirableAsync
      Specified by:
      expireAtAsync in interface RExpirableAsync
      Parameters:
      timestamp - - expire date
      Returns:
      true if the timeout was set and false if not
    • expireIfSet

      public boolean expireIfSet(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object only if it has been already set. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfSet in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfSetAsync

      public RFuture<Boolean> expireIfSetAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Sets a timeout for this object only if it has been already set. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfSetAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSet

      public boolean expireIfNotSet(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object only if it hasn't been set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfNotSet in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfNotSetAsync

      public RFuture<Boolean> expireIfNotSetAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Sets a timeout for this object only if it hasn't been set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfNotSetAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfGreater

      public boolean expireIfGreater(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object only if it's greater than timeout set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfGreater in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfGreaterAsync

      public RFuture<Boolean> expireIfGreaterAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Sets a timeout for this object only if it's greater than timeout set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfGreaterAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfLess

      public boolean expireIfLess(Duration duration)
      Description copied from interface: RExpirable
      Sets a timeout for this object only if it's less than timeout set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfLess in interface RExpirable
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • expireIfLessAsync

      public RFuture<Boolean> expireIfLessAsync(Duration duration)
      Description copied from interface: RExpirableAsync
      Sets a timeout for this object only if it's less than timeout set before. After the timeout has expired, the key will automatically be deleted.

      Requires Redis 7.0.0 and higher.

      Specified by:
      expireIfLessAsync in interface RExpirableAsync
      Parameters:
      duration - timeout before object will be deleted
      Returns:
      true if the timeout was set and false if not
    • clearExpire

      public boolean clearExpire()
      Description copied from interface: RExpirable
      Clear an expire timeout or expire date for object.
      Specified by:
      clearExpire in interface RExpirable
      Returns:
      true if timeout was removed false if object does not exist or does not have an associated timeout
    • clearExpireAsync

      public RFuture<Boolean> clearExpireAsync()
      Description copied from interface: RExpirableAsync
      Clear an expire timeout or expire date for object in async mode. Object will not be deleted.
      Specified by:
      clearExpireAsync in interface RExpirableAsync
      Returns:
      true if the timeout was cleared and false if not
    • remainTimeToLive

      public long remainTimeToLive()
      Description copied from interface: RExpirable
      Remaining time to live of Redisson object that has a timeout
      Specified by:
      remainTimeToLive in interface RExpirable
      Returns:
      time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
    • remainTimeToLiveAsync

      public RFuture<Long> remainTimeToLiveAsync()
      Description copied from interface: RExpirableAsync
      Remaining time to live of Redisson object that has a timeout
      Specified by:
      remainTimeToLiveAsync in interface RExpirableAsync
      Returns:
      time in milliseconds -2 if the key does not exist. -1 if the key exists but has no associated expire.
    • getExpireTime

      public long getExpireTime()
      Description copied from interface: RExpirable
      Expiration time of Redisson object that has a timeout

      Requires Redis 7.0.0 and higher.

      Specified by:
      getExpireTime in interface RExpirable
      Returns:
      expiration time
    • getExpireTimeAsync

      public RFuture<Long> getExpireTimeAsync()
      Description copied from interface: RExpirableAsync
      Expiration time of Redisson object that has a timeout

      Requires Redis 7.0.0 and higher.

      Specified by:
      getExpireTimeAsync in interface RExpirableAsync
      Returns:
      expiration time
    • expireAsync

      protected RFuture<Boolean> expireAsync(long timeToLive, TimeUnit timeUnit, String param, String... keys)
    • expireAtAsync

      protected RFuture<Boolean> expireAtAsync(long timestamp, String param, String... keys)
    • clearExpireAsync

      protected RFuture<Boolean> clearExpireAsync(String... keys)