Class RefreshAheadCacheConfiguration
- java.lang.Object
-
- net.sf.ehcache.constructs.refreshahead.RefreshAheadCacheConfiguration
-
- All Implemented Interfaces:
java.lang.Cloneable
public class RefreshAheadCacheConfiguration extends java.lang.Object implements java.lang.CloneableFluent configuration class forRefreshAheadCacheinstances.- Author:
- cschanck
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBATCH_SIZE_KEYProperties key for the batch size attributestatic java.lang.StringEVICT_ON_LOAD_MISSProperties key for the batch size attributestatic java.lang.StringMAX_BACKLOGProperties key for the max backlog attributestatic java.lang.StringNAME_KEYProperties key for the batch size attributestatic java.lang.StringNUMBER_OF_THREADS_KEYProperties key for the batch size attributestatic java.lang.StringTIME_TO_REFRESH_SECONDS_KEYProperties key for the batch size attribute
-
Constructor Summary
Constructors Constructor Description RefreshAheadCacheConfiguration()Create a default, valid configuration
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RefreshAheadCacheConfigurationbatchSize(int batchSize)Fluently set the batch size for processing refresh requests.RefreshAheadCacheConfigurationbuild()Validate this configuration.RefreshAheadCacheConfigurationevictOnLoadMiss(boolean loadMissEvicts)Fluently set whether no return for a key from all CacheLoaders should force an eviction prematurely from the underlying cache.RefreshAheadCacheConfigurationfromProperties(java.util.Properties properties)Initialize this configuration from aPropertiesobject.intgetBatchSize()Get the batch size with which refresh requests will be processed.intgetMaximumRefreshBacklogItems()Get the maximum number of backlog items allowed.java.lang.StringgetName()Get the name of this cache decoratorintgetNumberOfThreads()Get the number of threads used locally in this instance to process refresh requestslonggetTimeToRefreshMillis()return the time to refresh in milliseconds.longgetTimeToRefreshSeconds()Get the time to refresh in secondsbooleanisEvictOnLoadMiss()Get whether no return for a key from all CacheLoaders will force an eviction prematurely from the underlying cache.RefreshAheadCacheConfigurationmaximumRefreshBacklogItems(int maximumRefreshBacklogItems)Fluently set the maximum refresh backlog items.RefreshAheadCacheConfigurationname(java.lang.String name)Fluently set the name of this cache decoratorRefreshAheadCacheConfigurationnumberOfThreads(int numberOfThreads)Fluently set the number of threads used locally in this instance to process refresh requestsvoidsetBatchSize(int batchSize)Set the batch size for processing refresh requests.voidsetEvictOnLoadMiss(boolean loadMissEvicts)Set whether no return for a key from all CacheLoaders should force an eviction prematurely from the underlying cache.voidsetMaximumRefreshBacklogItems(int maximumRefreshBacklogItems)Set the maximum refresh backlog items.voidsetName(java.lang.String name)Set the name of this cache decoratorvoidsetNumberOfThreads(int numberOfThreads)Set the number of threads used locally in this instance to process refresh requestsvoidsetTimeToRefreshSeconds(long timeToRefreshSeconds)Set the time to refresh in secondsRefreshAheadCacheConfigurationtimeToRefreshSeconds(long secs)Fluently set the time to refresh secondsjava.util.PropertiestoProperties()Express this configuration as aPropertiesobject.java.lang.StringtoString()
-
-
-
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
-
-
Method Detail
-
fromProperties
public RefreshAheadCacheConfiguration fromProperties(java.util.Properties properties)
Initialize this configuration from aPropertiesobject. Will be validated before returning.- Parameters:
properties-- Returns:
- this configuration
-
toProperties
public java.util.Properties toProperties()
Express this configuration as aPropertiesobject.- 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:
toStringin classjava.lang.Object
-
-