Class LocalCachedMapOptions<K,V>
- Type Parameters:
K
- key typeV
- value type
- Author:
- Nikita Koksharov
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
static enum
Various strategies to avoid stale objects in local cache.static enum
static enum
Nested classes/interfaces inherited from class org.redisson.api.MapOptions
MapOptions.WriteMode
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
-
Method Summary
Modifier and TypeMethodDescriptioncacheProvider
(LocalCachedMapOptions.CacheProvider cacheProvider) Defines Cache provider used as local cache store.cacheSize
(int cacheSize) Defines local cache size.static <K,
V> LocalCachedMapOptions <K, V> defaults()
Creates a new instance of LocalCachedMapOptions with default options.evictionPolicy
(LocalCachedMapOptions.EvictionPolicy evictionPolicy) Defines local cache eviction policy.int
long
long
boolean
boolean
SetsMapLoader
object.loaderAsync
(MapLoaderAsync<K, V> loaderAsync) SetsMapLoaderAsync
object.maxIdle
(long maxIdleInMillis) Defines max idle time in milliseconds of each map entry in local cache.Defines max idle time of each map entry in local cache.reconnectionStrategy
(LocalCachedMapOptions.ReconnectionStrategy reconnectionStrategy) Defines strategy for load missed local cache updates after Redis connection failure.storeCacheMiss
(boolean storeCacheMiss) Defines whether to store a cache miss into the local cache.storeMode
(LocalCachedMapOptions.StoreMode storeMode) Defines store mode of cache data.syncStrategy
(LocalCachedMapOptions.SyncStrategy syncStrategy) Defines local cache synchronization strategy.timeToLive
(long timeToLiveInMillis) Defines time to live in milliseconds of each map entry in local cache.timeToLive
(long timeToLive, TimeUnit timeUnit) Defines time to live of each map entry in local cache.useKeyEventsPattern
(boolean useKeyEventsPattern) Defines whether to use __keyevent pattern topic to listen for expired events.writeBehindBatchSize
(int writeBehindBatchSize) Sets write behind tasks batch size.writeBehindDelay
(int writeBehindDelay) Sets write behind tasks execution delay.writeMode
(MapOptions.WriteMode writeMode) Sets write mode.DefinesMapWriter
object which is invoked during write operation.writerAsync
(MapWriterAsync<K, V> writer) DefinesMapWriterAsync
object which is invoked during write operation.Methods inherited from class org.redisson.api.MapOptions
getLoader, getLoaderAsync, getWriteBehindBatchSize, getWriteBehindDelay, getWriteMode, getWriter, getWriterAsync, getWriterRetryAttempts, getWriterRetryInterval, writerRetryAttempts, writerRetryInterval
-
Constructor Details
-
LocalCachedMapOptions
protected LocalCachedMapOptions() -
LocalCachedMapOptions
-
-
Method Details
-
defaults
Creates a new instance of LocalCachedMapOptions with default options.This is equivalent to:
new LocalCachedMapOptions() .cacheSize(0).timeToLive(0).maxIdle(0) .evictionPolicy(EvictionPolicy.NONE) .reconnectionStrategy(ReconnectionStrategy.NONE) .cacheProvider(CacheProvider.REDISSON) .syncStrategy(SyncStrategy.INVALIDATE) .storeCacheMiss(false);
- Type Parameters:
K
- key typeV
- value type- Returns:
- LocalCachedMapOptions instance
-
getCacheProvider
-
getEvictionPolicy
-
getCacheSize
public int getCacheSize() -
getTimeToLiveInMillis
public long getTimeToLiveInMillis() -
getMaxIdleInMillis
public long getMaxIdleInMillis() -
cacheSize
Defines local cache size.If size is
0
then local cache is unbounded.If size is
-1
then local cache is always empty and doesn't store data.- Parameters:
cacheSize
- size of cache- Returns:
- LocalCachedMapOptions instance
-
getReconnectionStrategy
-
getSyncStrategy
-
reconnectionStrategy
public LocalCachedMapOptions<K,V> reconnectionStrategy(LocalCachedMapOptions.ReconnectionStrategy reconnectionStrategy) Defines strategy for load missed local cache updates after Redis connection failure.- Parameters:
reconnectionStrategy
-CLEAR
- clear local cache if map instance has been disconnected for a while.LOAD
- store invalidated entry hash in invalidation log for 10 minutes. Cache keys for stored invalidated entry hashes will be removed if LocalCachedMap instance has been disconnected less than 10 minutes or whole cache will be cleaned otherwiseNONE
- Default. No reconnection handling- Returns:
- LocalCachedMapOptions instance
-
syncStrategy
Defines local cache synchronization strategy.- Parameters:
syncStrategy
-INVALIDATE
- Default. Invalidate cache entry across all LocalCachedMap instances on map entry changeUPDATE
- Insert/update cache entry across all LocalCachedMap instances on map entry changeNONE
- No synchronizations on map changes- Returns:
- LocalCachedMapOptions instance
-
evictionPolicy
public LocalCachedMapOptions<K,V> evictionPolicy(LocalCachedMapOptions.EvictionPolicy evictionPolicy) Defines local cache eviction policy.- Parameters:
evictionPolicy
-LRU
- uses local cache with LRU (least recently used) eviction policy.LFU
- uses local cache with LFU (least frequently used) eviction policy.SOFT
- uses local cache with soft references. The garbage collector will evict items from the local cache when the JVM is running out of memory.WEAK
- uses local cache with weak references. The garbage collector will evict items from the local cache when it became weakly reachable.NONE
- doesn't use eviction policy, but timeToLive and maxIdleTime params are still working.- Returns:
- LocalCachedMapOptions instance
-
timeToLive
Defines time to live in milliseconds of each map entry in local cache. If value equals to0
then timeout is not applied- Parameters:
timeToLiveInMillis
- - time to live in milliseconds- Returns:
- LocalCachedMapOptions instance
-
timeToLive
Defines time to live of each map entry in local cache. If value equals to0
then timeout is not applied- Parameters:
timeToLive
- - time to livetimeUnit
- - time unit- Returns:
- LocalCachedMapOptions instance
-
maxIdle
Defines max idle time in milliseconds of each map entry in local cache. If value equals to0
then timeout is not applied- Parameters:
maxIdleInMillis
- - time to live in milliseconds- Returns:
- LocalCachedMapOptions instance
-
maxIdle
Defines max idle time of each map entry in local cache. If value equals to0
then timeout is not applied- Parameters:
maxIdle
- - max idle timetimeUnit
- - time unit- Returns:
- LocalCachedMapOptions instance
-
getStoreMode
-
storeMode
Defines store mode of cache data.- Parameters:
storeMode
-LOCALCACHE
- store data in local cache only.LOCALCACHE_REDIS
- store data in both Redis and local cache.- Returns:
- LocalCachedMapOptions instance
-
cacheProvider
Defines Cache provider used as local cache store.- Parameters:
cacheProvider
-REDISSON
- uses Redisson own implementation.CAFFEINE
- uses Caffeine implementation.- Returns:
- LocalCachedMapOptions instance
-
isStoreCacheMiss
public boolean isStoreCacheMiss() -
storeCacheMiss
Defines whether to store a cache miss into the local cache.- Parameters:
storeCacheMiss
- - whether to store a cache miss into the local cache- Returns:
- LocalCachedMapOptions instance
-
isUseKeyEventsPattern
public boolean isUseKeyEventsPattern() -
useKeyEventsPattern
Defines whether to use __keyevent pattern topic to listen for expired events.- Parameters:
useKeyEventsPattern
- - whether to use __keyevent pattern topic- Returns:
- LocalCachedMapOptions instance
-
writeBehindBatchSize
Description copied from class:MapOptions
Sets write behind tasks batch size. All updates accumulated into a batch of specified size and written withMapWriter
.Default is
50
- Overrides:
writeBehindBatchSize
in classMapOptions<K,
V> - Parameters:
writeBehindBatchSize
- - size of batch- Returns:
- MapOptions instance
-
writeBehindDelay
Description copied from class:MapOptions
Sets write behind tasks execution delay. All updates written withMapWriter
and lag not more than specified delay.Default is
1000
milliseconds- Overrides:
writeBehindDelay
in classMapOptions<K,
V> - Parameters:
writeBehindDelay
- - delay in milliseconds- Returns:
- MapOptions instance
-
writer
Description copied from class:MapOptions
DefinesMapWriter
object which is invoked during write operation.- Overrides:
writer
in classMapOptions<K,
V> - Parameters:
writer
- object- Returns:
- MapOptions instance
-
writerAsync
Description copied from class:MapOptions
DefinesMapWriterAsync
object which is invoked during write operation.- Overrides:
writerAsync
in classMapOptions<K,
V> - Parameters:
writer
- object- Returns:
- MapOptions instance
-
writeMode
Description copied from class:MapOptions
Sets write mode.Default is
MapOptions.WriteMode.WRITE_THROUGH
- Overrides:
writeMode
in classMapOptions<K,
V> - Parameters:
writeMode
- - write mode- Returns:
- MapOptions instance
-
loader
Description copied from class:MapOptions
SetsMapLoader
object.- Overrides:
loader
in classMapOptions<K,
V> - Parameters:
loader
- object- Returns:
- MapOptions instance
-
loaderAsync
Description copied from class:MapOptions
SetsMapLoaderAsync
object.- Overrides:
loaderAsync
in classMapOptions<K,
V> - Parameters:
loaderAsync
- object- Returns:
- MapOptions instance
-