EchoPoint API - 3.0.0b5
App Webcontainer

echopoint.util.collections
Class TimerExpiryCache

java.lang.Object
  extended by echopoint.util.collections.ExpiryCache
      extended by echopoint.util.collections.TimerExpiryCache
All Implemented Interfaces:
Map

public class TimerExpiryCache
extends ExpiryCache

TimerExpiryCache is an a implementation of ExpiryCache that can contain objects that "expire". A shared background task will periodically "reap" objects that have "expired".

By default, soft references are used to the cached data so that they can be reclaimed in low memory conditions regardless of whether they have expired or not.

The time-to-live and access-timeout is used to decide when an object has expired and needs to be removed from the cache.

Time-to-live is simple. Once the specified period elapses, the object is removed from the cache, regardless of how many times its been accessed.

Access-timeout is a little more complicated. Each time the object is taken from the cache, its lastAccessTime is tracked. If the access-timeout has expired (since its last access) then the object is taken from the cache.

If both the time-to-live and access-timeout is -1, then the object will never expire from the cache.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static long DEFAULT_REAPER_INTERVAL
          The reaper interval is 2 minutes.
 
Fields inherited from class echopoint.util.collections.ExpiryCache
DEFAULT_ACCESS_TIMEOUT, DEFAULT_TIME_TO_LIVE
 
Constructor Summary
TimerExpiryCache()
          Constructs a default TimerExpiryCache
TimerExpiryCache(long timeToLive, long accessTimeout)
          Constructs a TimerExpiryCache
TimerExpiryCache(long timeToLive, long accessTimeout, boolean softReferences)
          Constructs a TimerExpiryCache with all the parameters
 
Method Summary
 
Methods inherited from class echopoint.util.collections.ExpiryCache
clear, containsKey, containsValue, entrySet, get, get, hasExpired, howManyTimesAccessed, isEmpty, isSoftReferences, keySet, onExpiredObject, put, put, put, put, putAll, remove, setAccessTimeout, setSoftReferences, setTimeToLive, size, values, whenCached, whenLastAccessed, whenVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

DEFAULT_REAPER_INTERVAL

public static final long DEFAULT_REAPER_INTERVAL
The reaper interval is 2 minutes. Therefore the cached object life span granulairty is +/- 1 minute.

See Also:
Constant Field Values
Constructor Detail

TimerExpiryCache

public TimerExpiryCache()
Constructs a default TimerExpiryCache


TimerExpiryCache

public TimerExpiryCache(long timeToLive,
                        long accessTimeout)
Constructs a TimerExpiryCache

Parameters:
timeToLive - - the default time-to-live for a cache entry
accessTimeout - - the default access timeout for a cache entry

TimerExpiryCache

public TimerExpiryCache(long timeToLive,
                        long accessTimeout,
                        boolean softReferences)
Constructs a TimerExpiryCache with all the parameters

Parameters:
timeToLive - - the default time-to-live for a cache entry
accessTimeout - - the default access timeout for a cache entry
softReferences - - whether soft refernces are used to cached data

EchoPoint API - 3.0.0b5
App Webcontainer