public class DistributedTimedCachePolicy extends TimerTask implements CachePolicy(Code)
An implementation of a timed cache. This is a cache whose entries have a
limited lifetime with the ability to refresh their lifetime. The entries
managed by the cache implement the TimedCachePolicy.TimedEntry interface. If
an object inserted into the cache does not implement this interface, it will
be wrapped in a DefaultTimedEntry and will expire without the possibility of
refresh after getDefaultLifetime() seconds.
This is a lazy cache policy in that objects are not checked for expiration
until they are accessed.
author: Scott Stark. version: $Revision: 57188 $
Inner Class :public static interface TimedEntry extends Serializable
Inner Class :static class DefaultTimedEntry implements TimedEntry
DistributedTimedCachePolicy(String category, String partitionName, int defaultLifetime) Creates a new TimedCachePolicy with the given default entry lifetime
that does not synchronized access to its policy store and uses a 60
second resolution.
public
DistributedTimedCachePolicy(String category, String partitionName, int defaultLifetime, int resolution) Creates a new TimedCachePolicy with the given default entry lifetime
that does/does not synchronized access to its policy store depending
on the value of threadSafe.
Parameters: category - the name of the catetegory used in the DistributedStateaccess calls. Parameters: partitionName - the name of the HAPartition who's replicatedstate service will be used as the cache store. Parameters: defaultLifetime - the lifetime in seconds to use for objects insertedthat do not implement the TimedEntry interface. Parameters: resolution - the resolution in seconds of the cache timer.
public DistributedTimedCachePolicy(String category, String partitionName, int defaultLifetime)(Code)
Creates a new TimedCachePolicy with the given default entry lifetime
that does not synchronized access to its policy store and uses a 60
second resolution.
DistributedTimedCachePolicy
public DistributedTimedCachePolicy(String category, String partitionName, int defaultLifetime, int resolution)(Code)
Creates a new TimedCachePolicy with the given default entry lifetime
that does/does not synchronized access to its policy store depending
on the value of threadSafe.
Parameters: category - the name of the catetegory used in the DistributedStateaccess calls. Parameters: partitionName - the name of the HAPartition who's replicatedstate service will be used as the cache store. Parameters: defaultLifetime - the lifetime in seconds to use for objects insertedthat do not implement the TimedEntry interface. Parameters: resolution - the resolution in seconds of the cache timer. A cache doesnot query the system time on every get() invocation. Rather the cacheupdates its notion of the current time every 'resolution' seconds. See Also:DistributedState
Get the cache value for key if it has not expired. If the TimedEntry
is expired its destroy method is called and then removed from the cache.
the TimedEntry value or the original value if it was not aninstance of TimedEntry if key is in the cache, null otherwise.
Insert a value into the cache. In order to have the cache entry
reshresh itself value would have to implement TimedEntry and
implement the required refresh() method logic.
Parameters: key - the key for the cache entry Parameters: value - Either an instance of TimedEntry that will be inserted withoutchange, or an abitrary value that will be wrapped in a non-refreshingTimedEntry.
Get the cache value for key. This method does not check to see if
the entry has expired.
the TimedEntry value or the original value if it was not aninstancee of TimedEntry if key is in the cache, null otherwise.
The TimerTask run method. It updates the cache time to the
current system time.
setDefaultLifetime
public void setDefaultLifetime(int defaultLifetime)(Code)
Set the default lifetime of cache entries for new values added to the cache.
Parameters: defaultLifetime - lifetime in seconds of cache values that donot implement TimedEntry.