Class LocalCachedMapOptions<K,​V>

  • Type Parameters:
    K - key type
    V - value type

    public class LocalCachedMapOptions<K,​V>
    extends MapOptions<K,​V>
    Configuration for LocalCachedMap object.
    Author:
    Nikita Koksharov
    • Constructor Detail

      • LocalCachedMapOptions

        protected LocalCachedMapOptions()
    • 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)
              .reconnectionStrategy(ReconnectionStrategy.NONE)
              .cacheProvider(CacheProvider.REDISSON)
              .syncStrategy(SyncStrategy.INVALIDATE)
              .storeCacheMiss(false);
         
        Type Parameters:
        K - key type
        V - value type
        Returns:
        LocalCachedMapOptions instance
      • getCacheSize

        public int getCacheSize()
      • getTimeToLiveInMillis

        public long getTimeToLiveInMillis()
      • getMaxIdleInMillis

        public long getMaxIdleInMillis()
      • cacheSize

        public LocalCachedMapOptions<K,​V> cacheSize​(int cacheSize)
        Defines local cache size. If size is 0 then local cache is unbounded.
        Parameters:
        cacheSize - - size of cache
        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

        public LocalCachedMapOptions<K,​V> timeToLive​(long timeToLiveInMillis)
        Defines time to live in milliseconds of each map entry in local cache. If value equals to 0 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)
        Defines time to live of each map entry in local cache. If value equals to 0 then timeout is not applied
        Parameters:
        timeToLive - - time to live
        timeUnit - - time unit
        Returns:
        LocalCachedMapOptions instance
      • maxIdle

        public LocalCachedMapOptions<K,​V> maxIdle​(long maxIdleInMillis)
        Defines max idle time in milliseconds of each map entry in local cache. If value equals to 0 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)
        Defines max idle time of each map entry in local cache. If value equals to 0 then timeout is not applied
        Parameters:
        maxIdle - - max idle time
        timeUnit - - time unit
        Returns:
        LocalCachedMapOptions instance
      • storeMode

        public LocalCachedMapOptions<K,​V> storeMode​(LocalCachedMapOptions.StoreMode 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

        public LocalCachedMapOptions<K,​V> cacheProvider​(LocalCachedMapOptions.CacheProvider 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

        public LocalCachedMapOptions<K,​V> storeCacheMiss​(boolean 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
      • writeBehindBatchSize

        public LocalCachedMapOptions<K,​V> writeBehindBatchSize​(int writeBehindBatchSize)
        Description copied from class: MapOptions
        Sets write behind tasks batch size. During MapWriter methods execution all updates accumulated into a batch of specified size.

        Default is 50

        Overrides:
        writeBehindBatchSize in class MapOptions<K,​V>
        Parameters:
        writeBehindBatchSize - - size of batch
        Returns:
        MapOptions instance
      • writeBehindDelay

        public LocalCachedMapOptions<K,​V> writeBehindDelay​(int writeBehindDelay)
        Description copied from class: MapOptions
        Sets write behind tasks execution delay. All updates would be applied with lag not more than specified delay.

        Default is 1000 milliseconds

        Overrides:
        writeBehindDelay in class MapOptions<K,​V>
        Parameters:
        writeBehindDelay - - delay in milliseconds
        Returns:
        MapOptions instance