Package com.axelor.cache.redisson
Class RedissonCacheNative<K,V>
java.lang.Object
com.axelor.cache.redisson.AbstractRedissonCache<K,V,org.redisson.api.RMapCacheNative<K,V>>
com.axelor.cache.redisson.RedissonCacheNative<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>>
public class RedissonCacheNative<K,V>
extends AbstractRedissonCache<K,V,org.redisson.api.RMapCacheNative<K,V>>
Redisson cache with native eviction
This implementation wraps a RMapCacheNative and relies on Redis
capabilities for handling entry expiration.
Important Note on Redis Version:
Setting Time-To-Live (TTL) requires the HPEXPIRE command, which was introduced in Redis
7.4. Ensure your Redis server version is compatible.
Limitations compared to standard RMapCache:
- Expire After Access: Not natively supported. This implementation falls back to
expireAfterWrite(TTL) and logs a warning. - Maximum Size: Not natively supported. This implementation falls back to a default TTL (1 hour) if no other TTL is set, and logs a warning.
-
Field Summary
Fields inherited from class com.axelor.cache.redisson.AbstractRedissonCache
cache -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAssociates thevaluewith thekey.voidCopies all of the mappings from the specified map to the cache.voidsetExpireAfterAccess(Duration expireAfterAccess) voidsetExpireAfterWrite(Duration expireAfterWrite) voidsetMaximumSize(int maximumSize) Methods inherited from class com.axelor.cache.redisson.AbstractRedissonCache
asMap, close, estimatedSize, get, getAll, getLock, invalidate, invalidateAllMethods 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
-
Constructor Details
-
RedissonCacheNative
-
-
Method Details
-
setExpireAfterWrite
- Specified by:
setExpireAfterWritein classAbstractRedissonCache<K,V, org.redisson.api.RMapCacheNative<K, V>>
-
setExpireAfterAccess
- Specified by:
setExpireAfterAccessin classAbstractRedissonCache<K,V, org.redisson.api.RMapCacheNative<K, V>>
-
setMaximumSize
public void setMaximumSize(int maximumSize) - Specified by:
setMaximumSizein classAbstractRedissonCache<K,V, org.redisson.api.RMapCacheNative<K, V>>
-
put
Description copied from interface:AxelorCacheAssociates thevaluewith thekey.- Specified by:
putin interfaceAxelorCache<K,V> - Overrides:
putin classAbstractRedissonCache<K,V, org.redisson.api.RMapCacheNative<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.RMapCacheNative<K, V>> - Parameters:
map- the mappings to be stored in this cache
-