Package com.axelor.cache.redisson
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 cacheV- the type of mapped values
- All Implemented Interfaces:
AxelorCache<K,,V> Closeable,AutoCloseable,Iterable<Map.Entry<K,V>>
- Direct Known Subclasses:
RedissonLoadingCache
Redisson cache with scripted eviction
This wraps a RMapCache.
-
Field Summary
Fields inherited from class com.axelor.cache.redisson.AbstractRedissonCache
cache -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddListener(org.redisson.api.map.event.MapEntryListener listener) voidclose()Signals that the cache is no longer in use and releases any resources.protected VcomputeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) Computes if absent with applied ttl and maxIdleTimeReturns the value associated with thekeyin this cache, obtaining that value from themappingFunctionif necessary.voidAssociates thevaluewith thekey.voidCopies all of the mappings from the specified map to the cache.voidremoveListener(int listenerId) voidsetExpireAfterAccess(Duration expireAfterAccess) voidsetExpireAfterWrite(Duration expireAfterWrite) voidsetMaximumSize(int maximumSize) Methods inherited from class com.axelor.cache.redisson.AbstractRedissonCache
asMap, clearExpire, estimatedSize, expire, get, getAll, getLock, invalidate, invalidateAll, remainTimeToLiveMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.axelor.cache.AxelorCache
cleanUp, iteratorMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
RedissonCache
-
-
Method Details
-
setExpireAfterWrite
- Specified by:
setExpireAfterWritein classAbstractRedissonCache<K,V, org.redisson.api.RMapCache<K, V>>
-
setExpireAfterAccess
- Specified by:
setExpireAfterAccessin classAbstractRedissonCache<K,V, org.redisson.api.RMapCache<K, V>>
-
setMaximumSize
public void setMaximumSize(int maximumSize) - Specified by:
setMaximumSizein classAbstractRedissonCache<K,V, org.redisson.api.RMapCache<K, V>>
-
get
Description copied from interface:AxelorCacheReturns the value associated with thekeyin this cache, obtaining that value from themappingFunctionif necessary.- Parameters:
key- the key with which the specified value is to be associatedmappingFunction- 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
Computes if absent with applied ttl and maxIdleTimeThe code follows
RedissonMapCache.computeIfAbsent(Object, Duration, Function)behavior.- Parameters:
key- key with which the specified value is to be associatedmappingFunction- mapping function to compute a value- Returns:
- existing or computed value
-
put
Description copied from interface:AxelorCacheAssociates thevaluewith thekey.- Specified by:
putin interfaceAxelorCache<K,V> - Overrides:
putin classAbstractRedissonCache<K,V, org.redisson.api.RMapCache<K, V>> - Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key
-
putAll
Description copied from interface:AxelorCacheCopies 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 fromkeytovaluein the specified map.- Specified by:
putAllin interfaceAxelorCache<K,V> - Overrides:
putAllin classAbstractRedissonCache<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:AxelorCacheSignals that the cache is no longer in use and releases any resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceAxelorCache<K,V> - Specified by:
closein interfaceCloseable- Overrides:
closein classAbstractRedissonCache<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)
-