Package com.axelor.cache.redisson
Class AbstractRedissonCache<K,V,M extends org.redisson.api.RMap<K,V>>
java.lang.Object
com.axelor.cache.redisson.AbstractRedissonCache<K,V,M>
- Type Parameters:
K- the type of keys maintained by this cacheV- the type of mapped valuesM- the type of Redisson map
- All Implemented Interfaces:
AxelorCache<K,,V> Closeable,AutoCloseable,Iterable<Map.Entry<K,V>>
- Direct Known Subclasses:
RedissonCache,RedissonCacheNative
public abstract class AbstractRedissonCache<K,V,M extends org.redisson.api.RMap<K,V>>
extends Object
implements AxelorCache<K,V>
Redisson cache with configurability of cache eviction policies.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasMap()Returns a view of the entries stored in this cache as a thread-safe map.voidclose()Signals that the cache is no longer in use and releases any resources.longReturns the approximate number of entries in this cache.Returns the value associated with thekeyin this cache, obtaining that value from theCacheLoaderif defined and if necessary, otherwise returnsnullif there is no cached value for thekey.Returns a map of the values associated with thekeysin this cache, usingCacheLoaderif defined and if necessary.Returns key-specific lock for this cache.voidinvalidate(K key) Discards any cached value for thekey.voidDiscards all cached values.voidAssociates thevaluewith thekey.voidCopies all of the mappings from the specified map to the cache.abstract voidsetExpireAfterAccess(Duration expireAfterAccess) abstract voidsetExpireAfterWrite(Duration expireAfterWrite) abstract voidsetMaximumSize(int maximumSize) Methods 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, get, iteratorMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
cache
-
-
Constructor Details
-
AbstractRedissonCache
-
-
Method Details
-
setExpireAfterWrite
-
setExpireAfterAccess
-
setMaximumSize
public abstract void setMaximumSize(int maximumSize) -
get
Description copied from interface:AxelorCacheReturns the value associated with thekeyin this cache, obtaining that value from theCacheLoaderif defined and if necessary, otherwise returnsnullif there is no cached value for thekey.- Specified by:
getin interfaceAxelorCache<K,V> - Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
nullif this map contains no mapping for the key
-
getAll
Description copied from interface:AxelorCacheReturns a map of the values associated with thekeysin this cache, usingCacheLoaderif defined and if necessary.- Specified by:
getAllin interfaceAxelorCache<K,V> - Parameters:
keys- the keys whose associated values are to be returned- Returns:
- an unmodifiable mapping of keys to values for the specified keys in this cache
-
put
Description copied from interface:AxelorCacheAssociates thevaluewith thekey.- Specified by:
putin interfaceAxelorCache<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> - Parameters:
map- the mappings to be stored in this cache
-
invalidate
Description copied from interface:AxelorCacheDiscards any cached value for thekey.- Specified by:
invalidatein interfaceAxelorCache<K,V> - Parameters:
key- the key whose mapping is to be removed from the cache
-
invalidateAll
public void invalidateAll()Description copied from interface:AxelorCacheDiscards all cached values.- Specified by:
invalidateAllin interfaceAxelorCache<K,V>
-
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
-
estimatedSize
public long estimatedSize()Description copied from interface:AxelorCacheReturns the approximate number of entries in this cache. The actual count may differ because of concurrent updates and pending invalidations.- Specified by:
estimatedSizein interfaceAxelorCache<K,V> - Returns:
- the estimated size of the cache
-
asMap
Description copied from interface:AxelorCacheReturns a view of the entries stored in this cache as a thread-safe map. Modifications made to the map directly affect the cache.Note that if the cache has a cache loader, it will be used. This differs from Caffeine's Cache#asMap() and is designed to match Redisson RMap behavior.
- Specified by:
asMapin interfaceAxelorCache<K,V> - Returns:
- a thread-safe view of this cache supporting
ConcurrentMapoperations
-
getLock
Description copied from interface:AxelorCacheReturns key-specific lock for this cache.- Specified by:
getLockin interfaceAxelorCache<K,V> - Parameters:
key-- Returns:
- reentrant lock
-