Package org.redisson

Class RedissonLocalCachedMap<K,​V>

    • Method Detail

      • containsKeyAsync

        public RFuture<Boolean> containsKeyAsync​(Object key)
        Description copied from interface: RMapAsync
        Returns true if this map contains map entry mapped by specified key, otherwise false
        Specified by:
        containsKeyAsync in interface RMapAsync<K,​V>
        Overrides:
        containsKeyAsync in class RedissonMap<K,​V>
        Parameters:
        key - - map key
        Returns:
        true if this map contains map entry mapped by specified key, otherwise false
      • containsValueAsync

        public RFuture<Boolean> containsValueAsync​(Object value)
        Description copied from interface: RMapAsync
        Returns true if this map contains any map entry with specified value, otherwise false
        Specified by:
        containsValueAsync in interface RMapAsync<K,​V>
        Overrides:
        containsValueAsync in class RedissonMap<K,​V>
        Parameters:
        value - - map value
        Returns:
        true if this map contains any map entry with specified value, otherwise false
      • getAsync

        public RFuture<V> getAsync​(Object key)
        Description copied from interface: RMapAsync
        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.

        Specified by:
        getAsync in interface RMapAsync<K,​V>
        Overrides:
        getAsync in class RedissonMap<K,​V>
        Parameters:
        key - the key
        Returns:
        the value mapped by defined key or null if value is absent
      • generateLogEntryId

        protected static byte[] generateLogEntryId​(byte[] keyHash)
      • createSyncMessage

        protected io.netty.buffer.ByteBuf createSyncMessage​(io.netty.buffer.ByteBuf mapKey,
                                                            io.netty.buffer.ByteBuf mapValue,
                                                            CacheKey cacheKey)
      • destroy

        public void destroy()
        Description copied from interface: RDestroyable
        Destroys object when it's not necessary anymore.
        Specified by:
        destroy in interface RDestroyable
      • getAllAsync

        public RFuture<Map<K,​V>> getAllAsync​(Set<K> keys)
        Description copied from interface: RMapAsync
        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.

        Specified by:
        getAllAsync in interface RMapAsync<K,​V>
        Overrides:
        getAllAsync in class RedissonMap<K,​V>
        Parameters:
        keys - - map keys
        Returns:
        Map slice
      • fastPutIfAbsentAsync

        public RFuture<Boolean> fastPutIfAbsentAsync​(K key,
                                                     V value)
        Description copied from interface: RMapAsync
        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 RMapAsync.putIfAbsentAsync(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.

        Specified by:
        fastPutIfAbsentAsync in interface RMapAsync<K,​V>
        Overrides:
        fastPutIfAbsentAsync in class RedissonMap<K,​V>
        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.
      • fastPutIfExistsAsync

        public RFuture<Boolean> fastPutIfExistsAsync​(K key,
                                                     V value)
        Description copied from interface: RMapAsync
        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 RMapAsync.putIfExistsAsync(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.

        Specified by:
        fastPutIfExistsAsync in interface RMapAsync<K,​V>
        Overrides:
        fastPutIfExistsAsync in class RedissonMap<K,​V>
        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.
      • preloadCache

        public void preloadCache()
        Description copied from interface: RLocalCachedMap
        Pre-warm the cached entries. Not guaranteed to load ALL values, but statistically will preload approximately all (all if no concurrent mutating activity). Entries are loaded in a batch with size of 10 elements.
        Specified by:
        preloadCache in interface RLocalCachedMap<K,​V>
      • preloadCache

        public void preloadCache​(int count)
        Description copied from interface: RLocalCachedMap
        Pre-warm the cached entries. Not guaranteed to load ALL values, but statistically will preload approximately all (all if no concurrent mutating activity) Entries are loaded in a batch. Batch size is defined by count param.
        Specified by:
        preloadCache in interface RLocalCachedMap<K,​V>
        Parameters:
        count - - size of batch
      • fastReplaceAsync

        public RFuture<Boolean> fastReplaceAsync​(K key,
                                                 V value)
        Description copied from interface: RMapAsync
        Replaces previous value with a new value mapped by specified key.

        Works faster than RMapAsync.replaceAsync(Object, Object) but not returning the previous value.

        Returns true if key exists and value was updated or false if key doesn't exists and value wasn't updated.

        If MapWriter is defined then new map entry is stored in write-through mode.

        Specified by:
        fastReplaceAsync in interface RMapAsync<K,​V>
        Overrides:
        fastReplaceAsync in class RedissonMap<K,​V>
        Parameters:
        key - - map key
        value - - map value
        Returns:
        true if key exists and value was updated. false if key doesn't exists and value wasn't updated.
      • replaceAsync

        public RFuture<V> replaceAsync​(K key,
                                       V value)
        Description copied from interface: RMapAsync
        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.

        Specified by:
        replaceAsync in interface RMapAsync<K,​V>
        Overrides:
        replaceAsync in class RedissonMap<K,​V>
        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
      • replaceAsync

        public RFuture<Boolean> replaceAsync​(K key,
                                             V oldValue,
                                             V newValue)
        Description copied from interface: RMapAsync
        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.

        Specified by:
        replaceAsync in interface RMapAsync<K,​V>
        Overrides:
        replaceAsync in class RedissonMap<K,​V>
        Parameters:
        key - - map key
        oldValue - - map old value
        newValue - - map new value
        Returns:
        true if value has been replaced otherwise false.
      • removeAsync

        public RFuture<Boolean> removeAsync​(Object key,
                                            Object value)
        Description copied from interface: RMapAsync
        Removes map entry only if it exists with specified key and value.

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

        Specified by:
        removeAsync in interface RMapAsync<K,​V>
        Overrides:
        removeAsync in class RedissonMap<K,​V>
        Parameters:
        key - - map key
        value - - map value
        Returns:
        true if map entry has been removed otherwise false.
      • putIfExistsAsync

        public RFuture<V> putIfExistsAsync​(K key,
                                           V value)
        Description copied from interface: RMapAsync
        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.

        Specified by:
        putIfExistsAsync in interface RMapAsync<K,​V>
        Overrides:
        putIfExistsAsync in class RedissonMap<K,​V>
        Parameters:
        key - - map key
        value - - map value
        Returns:
        null if key is doesn't exists in the hash and value hasn't been set. Previous value if key already exists in the hash and new value has been stored.
      • putIfAbsentAsync

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

        Specified by:
        putIfAbsentAsync in interface RMapAsync<K,​V>
        Overrides:
        putIfAbsentAsync in class RedissonMap<K,​V>
        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.
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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
      • 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