Package org.redisson.api
Class LocalCachedMapOptions<K,V>
- java.lang.Object
-
- org.redisson.api.MapOptions<K,V>
-
- org.redisson.api.LocalCachedMapOptions<K,V>
-
- Type Parameters:
K
- key typeV
- value type
public class LocalCachedMapOptions<K,V> extends MapOptions<K,V>
Configuration for LocalCachedMap object.- Author:
- Nikita Koksharov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LocalCachedMapOptions.EvictionPolicy
static class
LocalCachedMapOptions.InvalidationPolicy
Deprecated.static class
LocalCachedMapOptions.ReconnectionStrategy
Various strategies to avoid stale objects in cache.static class
LocalCachedMapOptions.SyncStrategy
-
Nested classes/interfaces inherited from class org.redisson.api.MapOptions
MapOptions.WriteMode
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LocalCachedMapOptions()
protected
LocalCachedMapOptions(LocalCachedMapOptions<K,V> copy)
-
Method Summary
-
Methods inherited from class org.redisson.api.MapOptions
getLoader, getWriteBehindThreads, getWriteMode, getWriter
-
-
-
-
Constructor Detail
-
LocalCachedMapOptions
protected LocalCachedMapOptions()
-
LocalCachedMapOptions
protected LocalCachedMapOptions(LocalCachedMapOptions<K,V> copy)
-
-
Method Detail
-
defaults
public static <K,V> LocalCachedMapOptions<K,V> 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) .invalidateEntryOnChange(true);
- Type Parameters:
K
- key typeV
- value type- Returns:
- LocalCachedMapOptions instance
-
getEvictionPolicy
public LocalCachedMapOptions.EvictionPolicy getEvictionPolicy()
-
getCacheSize
public int getCacheSize()
-
getTimeToLiveInMillis
public long getTimeToLiveInMillis()
-
getMaxIdleInMillis
public long getMaxIdleInMillis()
-
cacheSize
public LocalCachedMapOptions<K,V> cacheSize(int cacheSize)
Sets cache size. If size is0
then local cache is unbounded.- Parameters:
cacheSize
- - size of cache- Returns:
- LocalCachedMapOptions instance
-
getReconnectionStrategy
public LocalCachedMapOptions.ReconnectionStrategy getReconnectionStrategy()
-
getSyncStrategy
public LocalCachedMapOptions.SyncStrategy getSyncStrategy()
-
reconnectionStrategy
public LocalCachedMapOptions<K,V> reconnectionStrategy(LocalCachedMapOptions.ReconnectionStrategy reconnectionStrategy)
-
syncStrategy
public LocalCachedMapOptions<K,V> syncStrategy(LocalCachedMapOptions.SyncStrategy syncStrategy)
-
invalidationPolicy
@Deprecated public LocalCachedMapOptions<K,V> invalidationPolicy(LocalCachedMapOptions.InvalidationPolicy invalidationPolicy)
Deprecated.
-
invalidateEntryOnChange
@Deprecated public LocalCachedMapOptions<K,V> invalidateEntryOnChange(boolean value)
Deprecated.
-
evictionPolicy
public LocalCachedMapOptions<K,V> evictionPolicy(LocalCachedMapOptions.EvictionPolicy evictionPolicy)
Sets eviction policy.- Parameters:
evictionPolicy
-LRU
- uses cache with LRU (least recently used) eviction policy.LFU
- uses cache with LFU (least frequently used) eviction policy.SOFT
- uses cache with soft references. The garbage collector will evict items from the cache when the JVM is running out of memory.NONE
- doesn't use eviction policy, but timeToLive and maxIdleTime params are still working.- Returns:
- LocalCachedMapOptions instance
-
timeToLive
public LocalCachedMapOptions<K,V> timeToLive(long timeToLiveInMillis)
Sets time to live in milliseconds for each map entry in cache. If value equals to0
then timeout is not applied- Parameters:
timeToLiveInMillis
- - time to live in milliseconds- Returns:
- LocalCachedMapOptions instance
-
timeToLive
public LocalCachedMapOptions<K,V> timeToLive(long timeToLive, TimeUnit timeUnit)
Sets time to live for each map entry in cache. If value equals to0
then timeout is not applied- Parameters:
timeToLive
- - time to livetimeUnit
- - time unit- Returns:
- LocalCachedMapOptions instance
-
maxIdle
public LocalCachedMapOptions<K,V> maxIdle(long maxIdleInMillis)
Sets max idle time in milliseconds for each map entry in cache. If value equals to0
then timeout is not applied- Parameters:
maxIdleInMillis
- - time to live in milliseconds- Returns:
- LocalCachedMapOptions instance
-
maxIdle
public LocalCachedMapOptions<K,V> maxIdle(long maxIdle, TimeUnit timeUnit)
Sets max idle time for each map entry in cache. If value equals to0
then timeout is not applied- Parameters:
maxIdle
- - max idle timetimeUnit
- - time unit- Returns:
- LocalCachedMapOptions instance
-
writer
public LocalCachedMapOptions<K,V> writer(MapWriter<K,V> writer)
Description copied from class:MapOptions
SetsMapWriter
object.- Overrides:
writer
in classMapOptions<K,V>
- Parameters:
writer
- object- Returns:
- MapOptions instance
-
writeBehindThreads
public LocalCachedMapOptions<K,V> writeBehindThreads(int writeBehindThreads)
Description copied from class:MapOptions
Sets threads amount used in write behind mode.Default is
1
- Overrides:
writeBehindThreads
in classMapOptions<K,V>
- Parameters:
writeBehindThreads
- - threads amount- Returns:
- MapOptions instance
-
writeMode
public LocalCachedMapOptions<K,V> writeMode(MapOptions.WriteMode 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
public LocalCachedMapOptions<K,V> loader(MapLoader<K,V> loader)
Description copied from class:MapOptions
SetsMapLoader
object.- Overrides:
loader
in classMapOptions<K,V>
- Parameters:
loader
- object- Returns:
- MapOptions instance
-
-