|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.cache.eviction.BaseEvictionAlgorithm
org.jboss.cache.eviction.ExpirationAlgorithm
public class ExpirationAlgorithm
Eviction algorithm that uses a key in the Node data that indicates the time
the node should be evicted. The key must be a java.lang.Long object, with
the time to expire as milliseconds past midnight January 1st, 1970 UTC (the
same relative time as provided by System.currentTimeMillis()).
EvictionPolicyConfigBase.getMaxNodes(), and will evict the soonest to
expire entires first to reduce the region size. If there are not enough
nodes with expiration keys set, a warning is logged.
If a node in the eviction region does not have an expiration value, then
ExpirationConfiguration.getTimeToLiveSeconds() (if set) will be used.
The expiration is updated when a node is added or updated.
If there is no time-to-live set, and a node in the eviction region does not
have an expiration value, then that node will never be evicted. As
forgetting to indicate an expiration value is likely a mistake, a warning
message is logged by this class. This warning, however, can be disabled
through ExpirationConfiguration.setWarnNoExpirationKey(boolean).
A node's expiration time can be changed by setting a new value in the node.
Example usage:
Cache cache;
Fqn fqn1 = Fqn.fromString("/node/1");
Long future = new Long(System.currentTimeMillis() + 2000);
cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future);
cache.put(fqn1, "foo");
assertTrue(cache.get(fqn1) != null);
Thread.sleep(5000); // 5 seconds
assertTrue(cache.get(fqn1) == null);
| Field Summary |
|---|
| Fields inherited from class org.jboss.cache.eviction.BaseEvictionAlgorithm |
|---|
evictionQueue, recycleQueue, region |
| Constructor Summary | |
|---|---|
ExpirationAlgorithm(ExpirationPolicy policy)
Constructs a new algorithm with a policy. |
|
| Method Summary | |
|---|---|
protected void |
processQueues(Region region)
Event processing for Evict/Add/Visiting of nodes. |
protected void |
prune()
|
void |
resetEvictionQueue(Region region)
Reset the whole eviction queue. |
protected EvictionQueue |
setupEvictionQueue(Region region)
This method will create an EvictionQueue implementation and prepare it for use. |
protected boolean |
shouldEvictNode(NodeEntry ne)
This method will check whether the given node should be evicted or not. |
| Methods inherited from class org.jboss.cache.eviction.BaseEvictionAlgorithm |
|---|
emptyRecycleQueue, evict, evictCacheNode, getEvictionQueue, initialize, isNodeInUseAndNotTimedOut, process, processAddedElement, processAddedNodes, processMarkInUseNodes, processRemovedElement, processRemovedNodes, processUnmarkInUseNodes, processVisitedNodes, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ExpirationAlgorithm(ExpirationPolicy policy)
| Method Detail |
|---|
protected void processQueues(Region region)
throws EvictionException
BaseEvictionAlgorithm
processQueues in class BaseEvictionAlgorithmregion - Cache region to process for eviction.
EvictionException
protected void prune()
throws EvictionException
prune in class BaseEvictionAlgorithmEvictionExceptionpublic void resetEvictionQueue(Region region)
EvictionAlgorithm
resetEvictionQueue in interface EvictionAlgorithmresetEvictionQueue in class BaseEvictionAlgorithmregion - MarshRegion that this algorithm will operate on.
protected EvictionQueue setupEvictionQueue(Region region)
throws EvictionException
BaseEvictionAlgorithm
setupEvictionQueue in class BaseEvictionAlgorithmregion - MarshRegion to setup an eviction queue for.
EvictionExceptionEvictionQueueprotected boolean shouldEvictNode(NodeEntry ne)
BaseEvictionAlgorithm
shouldEvictNode in class BaseEvictionAlgorithmne - NodeEntry to test eviction for.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||