Specifying Expiration Attributes
Specifying Expiration Attributes
Expiration attributes govern the automatic eviction of regions and region entries from the cache. Eviction is based on the time elapsed since the last update or access to the object. This is referred to as the least-recently-used (LRU) eviction process. Expiration options range from marking the expired object as invalid to completely removing it from the distributed cache. Eviction can help keep data current by removing outdated entries, prompting a reload the next time they are requested. Eviction may also be used to recover space in the cache by clearing out unaccessed entries and regions.
Similar to application plug-ins, expiration activities are hosted by each application that defines a region in its cache.
<region-attributes> <entry-idle-time> <expiration-attributes timeout="60" action="local-invalidate"/> </entry-idle-time> </region-attributes>
Region and region entry expiration attributes are set at the region level. By default, regions and entries do not expire. The following attributes cover two types of expiration: time-to-live (TTL) and idle timeout.
|RegionTimeToLive||Number of seconds that the region remains in the cache after the last creation or update before the expiration action occurs.|
|EntryTimeToLive||For entries, the counter is set to zero for create and put operations. Region counters are reset when the region is created and when an entry has its counter reset. An update to an entry causes the time-to-live (TTL) counters to be reset for the entry and its region.|
|RegionIdleTimeout||Number of seconds that the region remains in the cache after the last access before the expiration action occurs.|
The idle timeout counter for an object is reset when
its TTL counter is reset. An entry's idle timeout counter is also
reset whenever the entry is accessed through a get
The idle timeout counter for a region is reset whenever the idle timeout is reset for one of its entries.
Using Statistics to Measure Expiration
Expiration is measured by comparing expiration attribute settings with the last accessed time and last modified time statistics. These statistics are directly available to applications through the CacheStatistics object that is returned by the Region::getStatistics and RegionEntry::getStatistics functions. The CacheStatistics object also provides a function for resetting the statistics counters.
You can specify one of the following actions for each expiration attribute:
- Destroy. Removes the object completely from the cache. For regions, all entries are destroyed as well. Destroy actions are distributed according to the region's distribution settings.
- Invalidate. Marks the object as invalid. For entries, the value is set to NULL. You invalidate a region by invalidating all its entries. Invalidate actions are distributed according to the region's distribution settings. When an entry is invalid, a get causes the cache to retrieve the entry according to the steps described in Entry Retrieval.
- Local destroy. Destroys the object in the local cache but does not distribute the operation.
Local invalidate. Invalidates
the object in the local cache but does not distribute the operation. Note: Destruction and invalidation cause the same event notification activities whether carried out explicitly or through expiration activities.
Expiration activities in distributed regions can be distributed or performed only in the local cache. So one cache could control region expiration for a number of caches in the distributed system.