Class RefreshAheadCacheConfiguration

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class RefreshAheadCacheConfiguration
    extends java.lang.Object
    implements java.lang.Cloneable
    Fluent configuration class for RefreshAheadCache instances.
    Author:
    cschanck
    • Field Detail

      • BATCH_SIZE_KEY

        public static final java.lang.String BATCH_SIZE_KEY
        Properties key for the batch size attribute
        See Also:
        Constant Field Values
      • NUMBER_OF_THREADS_KEY

        public static final java.lang.String NUMBER_OF_THREADS_KEY
        Properties key for the batch size attribute
        See Also:
        Constant Field Values
      • NAME_KEY

        public static final java.lang.String NAME_KEY
        Properties key for the batch size attribute
        See Also:
        Constant Field Values
      • TIME_TO_REFRESH_SECONDS_KEY

        public static final java.lang.String TIME_TO_REFRESH_SECONDS_KEY
        Properties key for the batch size attribute
        See Also:
        Constant Field Values
      • MAX_BACKLOG

        public static final java.lang.String MAX_BACKLOG
        Properties key for the max backlog attribute
        See Also:
        Constant Field Values
      • EVICT_ON_LOAD_MISS

        public static final java.lang.String EVICT_ON_LOAD_MISS
        Properties key for the batch size attribute
        See Also:
        Constant Field Values
    • Constructor Detail

      • RefreshAheadCacheConfiguration

        public RefreshAheadCacheConfiguration()
        Create a default, valid configuration
    • Method Detail

      • fromProperties

        public RefreshAheadCacheConfiguration fromProperties​(java.util.Properties properties)
        Initialize this configuration from a Properties object. Will be validated before returning.
        Parameters:
        properties -
        Returns:
        this configuration
      • toProperties

        public java.util.Properties toProperties()
        Express this configuration as a Properties object.
        Returns:
        properties version of this config
      • build

        public RefreshAheadCacheConfiguration build()
        Validate this configuration.
        Returns:
        validated configuration
        Throws:
        java.lang.IllegalStateException
      • getTimeToRefreshMillis

        public long getTimeToRefreshMillis()
        return the time to refresh in milliseconds.
        Returns:
      • timeToRefreshSeconds

        public RefreshAheadCacheConfiguration timeToRefreshSeconds​(long secs)
        Fluently set the time to refresh seconds
        Parameters:
        secs - seconds
        Returns:
        this config
      • getTimeToRefreshSeconds

        public long getTimeToRefreshSeconds()
        Get the time to refresh in seconds
        Returns:
        time to refresh in seconds
      • setTimeToRefreshSeconds

        public void setTimeToRefreshSeconds​(long timeToRefreshSeconds)
        Set the time to refresh in seconds
        Parameters:
        timeToRefreshSeconds -
      • getMaximumRefreshBacklogItems

        public int getMaximumRefreshBacklogItems()
        Get the maximum number of backlog items allowed. This is the max number of items that this local decorator will allow to be awaiting refresh at one time. If more requests are made than this, requests will begin to be thrown on the floor.
        Returns:
        max refresh backlog count
      • maximumRefreshBacklogItems

        public RefreshAheadCacheConfiguration maximumRefreshBacklogItems​(int maximumRefreshBacklogItems)
        Fluently set the maximum refresh backlog items.
        Parameters:
        maximumRefreshBacklogItems -
        Returns:
      • setMaximumRefreshBacklogItems

        public void setMaximumRefreshBacklogItems​(int maximumRefreshBacklogItems)
        Set the maximum refresh backlog items. This is the max number of items which can be queued for refresh processing; above this, keys that are candidates for refresh may be skipped. The correct setting for this will be deployment specific. Too low and refresh opportunities will be skipped; too high and refresh operations could come to dominate processing.
        Parameters:
        maximumRefreshBacklogItems -
      • getNumberOfThreads

        public int getNumberOfThreads()
        Get the number of threads used locally in this instance to process refresh requests
        Returns:
        number of threads
      • setNumberOfThreads

        public void setNumberOfThreads​(int numberOfThreads)
        Set the number of threads used locally in this instance to process refresh requests
        Parameters:
        numberOfThreads - number of threads
      • numberOfThreads

        public RefreshAheadCacheConfiguration numberOfThreads​(int numberOfThreads)
        Fluently set the number of threads used locally in this instance to process refresh requests
        Parameters:
        numberOfThreads - number of threads
        Returns:
        this config object
      • getBatchSize

        public int getBatchSize()
        Get the batch size with which refresh requests will be processed.
        Returns:
        batch size
      • setBatchSize

        public void setBatchSize​(int batchSize)
        Set the batch size for processing refresh requests.
        Parameters:
        batchSize - maximum batch size
      • batchSize

        public RefreshAheadCacheConfiguration batchSize​(int batchSize)
        Fluently set the batch size for processing refresh requests.
        Parameters:
        batchSize - maximum batch size
        Returns:
        this configuration object
      • getName

        public java.lang.String getName()
        Get the name of this cache decorator
        Returns:
        name
      • setName

        public void setName​(java.lang.String name)
        Set the name of this cache decorator
        Parameters:
        name -
      • name

        public RefreshAheadCacheConfiguration name​(java.lang.String name)
        Fluently set the name of this cache decorator
        Parameters:
        name -
        Returns:
      • isEvictOnLoadMiss

        public boolean isEvictOnLoadMiss()
        Get whether no return for a key from all CacheLoaders will force an eviction prematurely from the underlying cache.
      • setEvictOnLoadMiss

        public void setEvictOnLoadMiss​(boolean loadMissEvicts)
        Set whether no return for a key from all CacheLoaders should force an eviction prematurely from the underlying cache.
        Parameters:
        loadMissEvicts - true to evict
      • evictOnLoadMiss

        public RefreshAheadCacheConfiguration evictOnLoadMiss​(boolean loadMissEvicts)
        Fluently set whether no return for a key from all CacheLoaders should force an eviction prematurely from the underlying cache.
        Parameters:
        loadMissEvicts - true to evict
        Returns:
        this config
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object