10.4.5. ExpirationAlgorithm
org.jboss.cache.eviction.ExpirationAlgorithm is a policy that evicts nodes based on an absolute expiration time. The expiration time is indicated using the org.jboss.cache.Node.put() method, using a String key expiration and the absolute time as a java.lang.Long object, with a value indicated as milliseconds past midnight January 1st, 1970 UTC (the same relative time as provided by java.lang.System.currentTimeMillis() ).
This policy guarantees a constant order (
O (1) ) for adds and removals. Internally, a sorted set (TreeSet) containing the expiration time and Fqn of the nodes is stored, which essentially functions as a heap.
This policy has the following configuration parameters:
expirationKeyName- This is the Node key name used in the eviction algorithm. The configuration default isexpiration.maxNodes- This is the maximum number of nodes allowed in this region. 0 denotes immediate expiry, -1 denotes no limit.
The following listing shows how the expiration date is indicated and how the policy is applied:
Note that the expiration time of nodes is only checked when the region manager wakes up every
wakeUpIntervalSeconds , so eviction may happen a few seconds later than indicated.