BigMemory 4.3.7 | Product Documentation | BigMemory Max Developer Guide | Refresh Ahead | Inline Refresh Ahead
 
Inline Refresh Ahead
Inline refresh allows caches to automatically refresh entries based on a timer. Entries whose age reaches the configured time limit, and are accessed, are reloaded by the CacheLoader methods. For more information about the CacheLoader, see Implementing the CacheLoader.
Configuring Inline Refresh
Inline refresh ahead is configured per cache using a cache decorator. For information about using cache decorators, see Cache Decorators.
<cache ...
<cacheLoaderFactory class="com.company.my.ConcreteCacheLoaderFactory"
properties="some_property=1, some_other_property=2" />
<cacheDecorator class="net.sf.ehcache.constructs.refreshahead
  .RefreshAheadCacheFactory"
properties="name=myCacheRefresher,
timeToRefreshSeconds=200,
batchSize=10,
numberOfThreads=4,
maximumBacklogItems=100,
evictOnLoadMiss=true" />
</cacheDecorator>
...
</cache>
The cache-decorator class is required for implementing the refresh-ahead mechanism. Note that inline-refresh configuration properties are optional unless marked REQUIRED. The following table describes these properties.
Property
Definition
Default Value
name
The name used to identify the cache decorator. If left null, the cache decorator is accessed instead of the underlying cache when the cache's name is referenced.
N/A
timeToRefreshSeconds
REQUIRED. The number of seconds an entry can exist in the cache before it is refreshed (reloaded) on access. Expired items that have yet to be evicted cannot be refreshed.
N/A
maximumBacklogItems
REQUIRED. The maximum number of refresh requests allowed in the refresh work queue. Once this limit is exceeded, items are dropped from the queue to prevent potentially overtaxing resources. If refresh requests are queued faster than they are being cleared, this limit can be exceeded.
N/A
batchSize
The maximum number of refresh requests that can be batched for processing by a thread. For more frequent processing of requests—at a cost to performance—lower the value.
100
numberOfThreads
The number of threads to use for background refresh operations on the decorator. If multiple cache loaders are configured, refresh operations occur in turn.
1
evictOnLoadMiss
A boolean to force an immediate eviction on a reload miss (true) or to not evict before normal eviction takes effect (false). If true, entries that do not refresh due to a failure of the reload operation (all cacheloaders fail) are evicted even if they have not expired based on time-to-live or time-to-idle settings.
false
How timeToRefreshSeconds Works With Expiration
The timeToRefreshSeconds value is at least how old an entry must be before a get operation triggers an automatic refresh. The refresh is a reload operation that resets an entry's time-to-live (TTL) countdown. A Time-to-idle (TTI) setting is reset upon access and so has no effect if it is greater than the refresh time limit (TTR), unless no access occurs.
For example, for a cache with a TTR of 10 seconds, a TTL of 30 seconds, and a TTI of 0 (infinite idle time), any access to an entry that occurs between 10 and 30 seconds triggers an automatic refresh of that entry. This assumes that the entry is reloaded ahead of the TTL limit so that the TTL timer is reset.