ehcache

net.sf.ehcache.constructs.refreshahead
Class RefreshAheadCacheConfiguration

java.lang.Object
  extended by net.sf.ehcache.constructs.refreshahead.RefreshAheadCacheConfiguration
All Implemented Interfaces:
Cloneable

public class RefreshAheadCacheConfiguration
extends Object
implements Cloneable

Fluent configuration class for RefreshAheadCache instances.

Author:
cschanck

Field Summary
static String BATCH_SIZE_KEY
          Properties key for the batch size attribute
static String EVICT_ON_LOAD_MISS
          Properties key for the batch size attribute
static String MAX_BACKLOG
          Properties key for the max backlog attribute
static String NAME_KEY
          Properties key for the batch size attribute
static String NUMBER_OF_THREADS_KEY
          Properties key for the batch size attribute
static String TIME_TO_REFRESH_SECONDS_KEY
          Properties key for the batch size attribute
 
Constructor Summary
RefreshAheadCacheConfiguration()
          Create a default, valid configuration
 
Method Summary
 RefreshAheadCacheConfiguration batchSize(int batchSize)
          Fluently set the batch size for processing refresh requests.
 RefreshAheadCacheConfiguration build()
          Validate this configuration.
 RefreshAheadCacheConfiguration evictOnLoadMiss(boolean loadMissEvicts)
          Fluently set whether no return for a key from all CacheLoaders should force an eviction prematurely from the underlying cache.
 RefreshAheadCacheConfiguration fromProperties(Properties properties)
          Initialize this configuration from a Properties object.
 int getBatchSize()
          Get the batch size with which refresh requests will be processed.
 int getMaximumRefreshBacklogItems()
          Get the maximum number of backlog items allowed.
 String getName()
          Get the name of this cache decorator
 int getNumberOfThreads()
          Get the number of threads used locally in this instance to process refresh requests
 long getTimeToRefreshMillis()
          return the time to refresh in milliseconds.
 long getTimeToRefreshSeconds()
          Get the time to refresh in seconds
 boolean isEvictOnLoadMiss()
          Get whether no return for a key from all CacheLoaders will force an eviction prematurely from the underlying cache.
 RefreshAheadCacheConfiguration maximumRefreshBacklogItems(int maximumRefreshBacklogItems)
          Fluently set the maximum refresh backlog items.
 RefreshAheadCacheConfiguration name(String name)
          Fluently set the name of this cache decorator
 RefreshAheadCacheConfiguration numberOfThreads(int numberOfThreads)
          Fluently set the number of threads used locally in this instance to process refresh requests
 void setBatchSize(int batchSize)
          Set the batch size for processing refresh requests.
 void setEvictOnLoadMiss(boolean loadMissEvicts)
          Set whether no return for a key from all CacheLoaders should force an eviction prematurely from the underlying cache.
 void setMaximumRefreshBacklogItems(int maximumRefreshBacklogItems)
          Set the maximum refresh backlog items.
 void setName(String name)
          Set the name of this cache decorator
 void setNumberOfThreads(int numberOfThreads)
          Set the number of threads used locally in this instance to process refresh requests
 void setTimeToRefreshSeconds(long timeToRefreshSeconds)
          Set the time to refresh in seconds
 RefreshAheadCacheConfiguration timeToRefreshSeconds(long secs)
          Fluently set the time to refresh seconds
 Properties toProperties()
          Express this configuration as a Properties object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BATCH_SIZE_KEY

public static final String BATCH_SIZE_KEY
Properties key for the batch size attribute

See Also:
Constant Field Values

NUMBER_OF_THREADS_KEY

public static final String NUMBER_OF_THREADS_KEY
Properties key for the batch size attribute

See Also:
Constant Field Values

NAME_KEY

public static final String NAME_KEY
Properties key for the batch size attribute

See Also:
Constant Field Values

TIME_TO_REFRESH_SECONDS_KEY

public static final String TIME_TO_REFRESH_SECONDS_KEY
Properties key for the batch size attribute

See Also:
Constant Field Values

MAX_BACKLOG

public static final String MAX_BACKLOG
Properties key for the max backlog attribute

See Also:
Constant Field Values

EVICT_ON_LOAD_MISS

public static final 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(Properties properties)
Initialize this configuration from a Properties object. Will be validated before returning.

Parameters:
properties -
Returns:
this configuration

toProperties

public 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:
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 String getName()
Get the name of this cache decorator

Returns:
name

setName

public void setName(String name)
Set the name of this cache decorator

Parameters:
name -

name

public RefreshAheadCacheConfiguration name(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 String toString()
Overrides:
toString in class Object

ehcache

Copyright 2001-2015, Terracotta, Inc.