Class RedissonCache<K,V>

java.lang.Object
com.axelor.cache.redisson.AbstractRedissonCache<K,V,org.redisson.api.RMapCache<K,V>>
com.axelor.cache.redisson.RedissonCache<K,V>
Type Parameters:
K - the type of keys maintained by this cache
V - the type of mapped values
All Implemented Interfaces:
AxelorCache<K,V>, Closeable, AutoCloseable, Iterable<Map.Entry<K,V>>
Direct Known Subclasses:
RedissonLoadingCache

public class RedissonCache<K,V> extends AbstractRedissonCache<K,V,org.redisson.api.RMapCache<K,V>>
Redisson cache with scripted eviction

This wraps a RMapCache.

  • Constructor Details

    • RedissonCache

      public RedissonCache(org.redisson.api.RMapCache<K,V> cache)
  • Method Details

    • setExpireAfterWrite

      public void setExpireAfterWrite(Duration expireAfterWrite)
      Specified by:
      setExpireAfterWrite in class AbstractRedissonCache<K,V,org.redisson.api.RMapCache<K,V>>
    • setExpireAfterAccess

      public void setExpireAfterAccess(Duration expireAfterAccess)
      Specified by:
      setExpireAfterAccess in class AbstractRedissonCache<K,V,org.redisson.api.RMapCache<K,V>>
    • setMaximumSize

      public void setMaximumSize(int maximumSize)
      Specified by:
      setMaximumSize in class AbstractRedissonCache<K,V,org.redisson.api.RMapCache<K,V>>
    • get

      public V get(K key, Function<? super K,? extends V> mappingFunction)
      Description copied from interface: AxelorCache
      Returns the value associated with the key in this cache, obtaining that value from the mappingFunction if necessary.
      Parameters:
      key - the key with which the specified value is to be associated
      mappingFunction - the function to compute a value
      Returns:
      the current (existing or computed) value associated with the specified key, or null if the computed value is null
    • computeIfAbsent

      protected V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
      Computes if absent with applied ttl and maxIdleTime

      The code follows RedissonMapCache.computeIfAbsent(Object, Duration, Function) behavior.

      Parameters:
      key - key with which the specified value is to be associated
      mappingFunction - mapping function to compute a value
      Returns:
      existing or computed value
    • put

      public void put(K key, V value)
      Description copied from interface: AxelorCache
      Associates the value with the key.
      Specified by:
      put in interface AxelorCache<K,V>
      Overrides:
      put in class AbstractRedissonCache<K,V,org.redisson.api.RMapCache<K,V>>
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
    • putAll

      public void putAll(Map<? extends K,? extends V> map)
      Description copied from interface: AxelorCache
      Copies all of the mappings from the specified map to the cache.

      The effect of this call is equivalent to that of calling put(key, value) on this map once for each mapping from key to value in the specified map.

      Specified by:
      putAll in interface AxelorCache<K,V>
      Overrides:
      putAll in class AbstractRedissonCache<K,V,org.redisson.api.RMapCache<K,V>>
      Parameters:
      map - the mappings to be stored in this cache
    • close

      public void close()
      Description copied from interface: AxelorCache
      Signals that the cache is no longer in use and releases any resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface AxelorCache<K,V>
      Specified by:
      close in interface Closeable
      Overrides:
      close in class AbstractRedissonCache<K,V,org.redisson.api.RMapCache<K,V>>
    • addListener

      public int addListener(org.redisson.api.map.event.MapEntryListener listener)
    • removeListener

      public void removeListener(int listenerId)