K
- key typeV
- value typepublic class LocalCachedMapOptions<K,V> extends MapOptions<K,V>
Modifier and Type | Class and Description |
---|---|
static class |
LocalCachedMapOptions.CacheProvider |
static class |
LocalCachedMapOptions.EvictionPolicy |
static class |
LocalCachedMapOptions.ReconnectionStrategy
Various strategies to avoid stale objects in local cache.
|
static class |
LocalCachedMapOptions.StoreMode |
static class |
LocalCachedMapOptions.SyncStrategy |
MapOptions.WriteMode
Modifier | Constructor and Description |
---|---|
protected |
LocalCachedMapOptions() |
protected |
LocalCachedMapOptions(LocalCachedMapOptions<K,V> copy) |
getLoader, getWriteBehindBatchSize, getWriteBehindDelay, getWriteMode, getWriter
protected LocalCachedMapOptions()
protected LocalCachedMapOptions(LocalCachedMapOptions<K,V> copy)
public static <K,V> LocalCachedMapOptions<K,V> defaults()
This is equivalent to:
new LocalCachedMapOptions() .cacheSize(0).timeToLive(0).maxIdle(0) .evictionPolicy(EvictionPolicy.NONE) .reconnectionStrategy(ReconnectionStrategy.NONE) .cacheProvider(CacheProvider.REDISSON) .syncStrategy(SyncStrategy.INVALIDATE);
K
- key typeV
- value typepublic LocalCachedMapOptions.CacheProvider getCacheProvider()
public LocalCachedMapOptions.EvictionPolicy getEvictionPolicy()
public int getCacheSize()
public long getTimeToLiveInMillis()
public long getMaxIdleInMillis()
public LocalCachedMapOptions<K,V> cacheSize(int cacheSize)
0
then local cache is unbounded.cacheSize
- - size of cachepublic LocalCachedMapOptions.ReconnectionStrategy getReconnectionStrategy()
public LocalCachedMapOptions.SyncStrategy getSyncStrategy()
public LocalCachedMapOptions<K,V> reconnectionStrategy(LocalCachedMapOptions.ReconnectionStrategy reconnectionStrategy)
public LocalCachedMapOptions<K,V> syncStrategy(LocalCachedMapOptions.SyncStrategy syncStrategy)
public LocalCachedMapOptions<K,V> evictionPolicy(LocalCachedMapOptions.EvictionPolicy evictionPolicy)
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.
public LocalCachedMapOptions<K,V> timeToLive(long timeToLiveInMillis)
0
then timeout is not appliedtimeToLiveInMillis
- - time to live in millisecondspublic LocalCachedMapOptions<K,V> timeToLive(long timeToLive, TimeUnit timeUnit)
0
then timeout is not appliedtimeToLive
- - time to livetimeUnit
- - time unitpublic LocalCachedMapOptions<K,V> maxIdle(long maxIdleInMillis)
0
then timeout is not appliedmaxIdleInMillis
- - time to live in millisecondspublic LocalCachedMapOptions<K,V> maxIdle(long maxIdle, TimeUnit timeUnit)
0
then timeout is not appliedmaxIdle
- - max idle timetimeUnit
- - time unitpublic LocalCachedMapOptions.StoreMode getStoreMode()
public LocalCachedMapOptions<K,V> storeMode(LocalCachedMapOptions.StoreMode storeMode)
storeMode
- LOCALCACHE
- store data in local cache only.
LOCALCACHE_REDIS
- store data in both Redis and local cache.
public LocalCachedMapOptions<K,V> cacheProvider(LocalCachedMapOptions.CacheProvider cacheProvider)
cacheProvider
- REDISSON
- uses Redisson own implementation.
CAFFEINE
- uses Caffeine implementation.
public LocalCachedMapOptions<K,V> writeBehindBatchSize(int writeBehindBatchSize)
MapOptions
Default is 50
writeBehindBatchSize
in class MapOptions<K,V>
writeBehindBatchSize
- - size of batchpublic LocalCachedMapOptions<K,V> writeBehindDelay(int writeBehindDelay)
MapOptions
Default is 1000
milliseconds
writeBehindDelay
in class MapOptions<K,V>
writeBehindDelay
- - delay in millisecondspublic LocalCachedMapOptions<K,V> writer(MapWriter<K,V> writer)
MapOptions
MapWriter
object.writer
in class MapOptions<K,V>
writer
- objectpublic LocalCachedMapOptions<K,V> writeMode(MapOptions.WriteMode writeMode)
MapOptions
Default is MapOptions.WriteMode.WRITE_THROUGH
writeMode
in class MapOptions<K,V>
writeMode
- - write modepublic LocalCachedMapOptions<K,V> loader(MapLoader<K,V> loader)
MapOptions
MapLoader
object.loader
in class MapOptions<K,V>
loader
- objectCopyright © 2014–2020 Redisson. All rights reserved.