Package org.redisson

Class MapCacheNativeWrapper<K,V>

All Implemented Interfaces:
ConcurrentMap<K,V>, Map<K,V>, RDestroyable, RExpirable, RExpirableAsync, RMap<K,V>, RMapAsync<K,V>, RMapCache<K,V>, RMapCacheAsync<K,V>, RObject, RObjectAsync

public class MapCacheNativeWrapper<K,V> extends RedissonMapCache<K,V>
  • Constructor Details

  • Method Details

    • getWithTTLOnly

      public V getWithTTLOnly(K key)
      Description copied from interface: RMapCache
      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.

      NOTE: Idle time of entry is not taken into account. Entry last access time isn't modified if map limited by size.

      Specified by:
      getWithTTLOnly in interface RMapCache<K,V>
      Overrides:
      getWithTTLOnly in class RedissonMapCache<K,V>
      Parameters:
      key - the key
      Returns:
      the value mapped by defined key or null if value is absent
    • fastPut

      public boolean fastPut(K key, V value)
      Description copied from interface: RMap
      Stores the specified value mapped by specified key.

      Works faster than RMap.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.

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

      public RFuture<Boolean> fastPutAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
      Description copied from interface: RMapCacheAsync
      Stores value mapped by key with specified time to live and max idle time. Entry expires when specified time to live or max idle time has expired.

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

      Works faster than usual RMapCacheAsync.putAsync(Object, Object, long, TimeUnit, long, TimeUnit) as it not returns previous value.

      Specified by:
      fastPutAsync in interface RMapCacheAsync<K,V>
      Overrides:
      fastPutAsync in class RedissonMapCache<K,V>
      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.
      ttlUnit - - time unit
      maxIdleTime - - max idle time for key\value entry. If 0 then max idle time doesn't affect entry expiration.
      maxIdleUnit - - time unit

      if maxIdleTime and ttl params are equal to 0 then entry 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.
    • fastPut

      public boolean fastPut(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
      Description copied from interface: RMapCache
      Stores value mapped by key with specified time to live and max idle time. Entry expires when specified time to live or max idle time has expired.

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

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

      Specified by:
      fastPut in interface RMapCache<K,V>
      Overrides:
      fastPut in class RedissonMapCache<K,V>
      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.
      ttlUnit - - time unit
      maxIdleTime - - max idle time for key\value entry. If 0 then max idle time doesn't affect entry expiration.
      maxIdleUnit - - time unit

      if maxIdleTime and ttl params are equal to 0 then entry 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

      public RFuture<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
      Description copied from interface: RMapCacheAsync
      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 and max idle time. Entry expires when specified time to live or max idle time has expired.

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

      Specified by:
      putIfAbsentAsync in interface RMapCacheAsync<K,V>
      Overrides:
      putIfAbsentAsync in class RedissonMapCache<K,V>
      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.
      ttlUnit - - time unit
      maxIdleTime - - max idle time for key\value entry. If 0 then max idle time doesn't affect entry expiration.
      maxIdleUnit - - time unit

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

      Returns:
      previous associated value
    • putIfAbsent

      public V putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit)
      Description copied from interface: RMapCache
      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 and max idle time. Entry expires when specified time to live or max idle time has expired.

      Specified by:
      putIfAbsent in interface RMapCache<K,V>
      Overrides:
      putIfAbsent in class RedissonMapCache<K,V>
      Parameters:
      key - - map key
      value - - map value
      ttl - - time to live for key\value entry. If 0 then time to live doesn't affect entry expiration.
      ttlUnit - - time unit
      maxIdleTime - - max idle time for key\value entry. If 0 then max idle time doesn't affect entry expiration.
      maxIdleUnit - - time unit

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

      Returns:
      current associated value
    • containsKey

      public boolean containsKey(Object key)
      Description copied from interface: RMap
      Returns true if this map contains map entry mapped by specified key, otherwise false
      Specified by:
      containsKey in interface Map<K,V>
      Specified by:
      containsKey in interface RMap<K,V>
      Overrides:
      containsKey in class RedissonMap<K,V>
      Parameters:
      key - - map key
      Returns:
      true if this map contains map entry mapped by specified key, otherwise false
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
      Overrides:
      clear in class RedissonMapCache<K,V>
    • clearAsync

      public RFuture<Boolean> clearAsync()
      Description copied from interface: RMapAsync
      Clears map without removing options data used during map creation.
      Specified by:
      clearAsync in interface RMapAsync<K,V>
      Overrides:
      clearAsync in class RedissonMapCache<K,V>
      Returns:
      true if map was cleared false if not
    • fastRemove

      public long fastRemove(K... keys)
      Description copied from interface: RMap
      Removes map entries mapped by specified keys.

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

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

      Specified by:
      fastRemove in interface RMap<K,V>
      Overrides:
      fastRemove in class RedissonMap<K,V>
      Parameters:
      keys - - map keys
      Returns:
      the number of keys that were removed from the hash, not including specified but non existing keys
    • destroy

      public void destroy()
      Description copied from interface: RDestroyable
      Destroys object when it's not necessary anymore.
      Specified by:
      destroy in interface RDestroyable
      Overrides:
      destroy in class RedissonMapCache<K,V>
    • 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
    • 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
    • clearExpireAsync

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