|
02/28/2005 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--com.vignette.portal.cache.CacheStrategy
|
+--com.vignette.portal.cache.ActionBasedCacheStrategy
|
+--com.vignette.portal.cache.TimeBasedStrategy
Removes entries from the cache after a given amount of time has elapsed. Subclasses implement specific algorithms for measuring the elapsed time.
Callers can provide overrides to the configuration parameters
with every call to the cache via an optional Map parameter.
This strategy and its subclasses will look in this map for the
key TimeBasedStrategy.getOverrideTimeoutProperty() and an associated value of
type Number to use instead of the value passed at constrction
time and use it to compute the entry's expiration time.
This strategy and its subclasses will also look in this map for
the key TimeBasedStrategy.getNeverExpireProperty() and if present, will not expire
the given entry at any time.
This strategy implements the Periodical interface and checks the
expiration times as part of its TimeBasedStrategy.onPeriod(long) method. Between periods,
nothing gets expired. This means that the expiration time for entries has
a resolution that is governed by how often the TimeBasedStrategy.onPeriod(long) method is
called, which is beyond the control of the user of this API.
| Constructor Summary | |
TimeBasedStrategy(CacheAction action,
long defaultTimeout)
Creates a cache with specified timeout and with specified action logic. |
|
TimeBasedStrategy(long defaultTimeout)
Creates a cache with specified timeout and with default action logic. |
|
| Method Summary | |
protected boolean |
containsKey(Object key)
|
long |
getDefaultTimeout()
|
Object |
getNeverExpireProperty()
Get the key to be used for the never expire override property. |
Object |
getOverrideTimeoutProperty()
Get the key to be used for the expiration timeout override property. |
void |
onAdd(Object key,
Object value,
Map properties)
Signals addition to the cache. |
void |
onInvalidate(Object key)
Someone wants to remove key from the cache. |
void |
onInvalidateAll()
Someone wants to remove all keys from the cache. |
void |
onInvalidateAll(Collection keys)
Someone wants to remove keys from the cache. |
void |
onPeriod(long now)
|
void |
onPut(Object key,
Object value,
Map properties)
Someone wants to add the pair key / value
to the cache. |
void |
onPutAll(Map keyValuePairs,
Map properties)
Someone wants to add the pairs in keyValuePairs to the
cache. |
void |
onRemove(Object key)
Signals removal from the cache. |
void |
onRemoveAll()
Signals clearing of the cache. |
void |
onRemoveAll(Collection keys)
Signals removals from the cache. |
protected boolean |
updateExpirationTime(Object key,
Map properties)
Update the expiration time for the key |
| Methods inherited from class com.vignette.portal.cache.ActionBasedCacheStrategy |
getCacheAction, setStore |
| Methods inherited from class com.vignette.portal.cache.CacheStrategy |
getStore, onAddAll, onGet, onGetAll |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TimeBasedStrategy(long defaultTimeout)
throws IllegalArgumentException
Creates a cache with specified timeout and with default action logic.
defaultTimeout - the maximum time, in milliseconds, that objects are allowed in the cache.ActionBasedCacheStrategy.ActionBasedCacheStrategy()
public TimeBasedStrategy(CacheAction action,
long defaultTimeout)
throws IllegalArgumentException
Creates a cache with specified timeout and with specified action logic.
action - the non-null action to invoke when the size of the cache is exceeded.defaultTimeout - the maximum time, in milliseconds, that objects are allowed in the cache.ActionBasedCacheStrategy.ActionBasedCacheStrategy(CacheAction)| Method Detail |
public final Object getNeverExpireProperty()
public final Object getOverrideTimeoutProperty()
public long getDefaultTimeout()
public void onPut(Object key,
Object value,
Map properties)
throws CacheException
CacheStrategySomeone wants to add the pair key / value
to the cache. This strategy can reject the operation by throwing an
exception. The actual addition, if allowed, will be signalled later by
a call to this strategy's onAdd method.
Individual strategies can use the information in
properties to override their creation-time parameters.
onPut in class CacheStrategycom.vignette.portal.cache.CacheStrategykey - key being addedvalue - value being added, matching keyproperties - possible overrides, can be null
public void onPutAll(Map keyValuePairs,
Map properties)
throws CacheException
CacheStrategySomeone wants to add the pairs in keyValuePairs to the
cache. This strategy can reject the operation by throwing an
exception. The actual addition, if allowed, will be signalled later
by a call to this strategy's onAddAll method.
Individual strategies can use the information in
properties to override their creation-time parameters.
This is a default implementation. For performance purposes you may wish to override it. If you do, you should not be calling super.onPutAll(Map, Map).
onPutAll in class CacheStrategycom.vignette.portal.cache.CacheStrategykeyValuePairs - key/value pairs being addedproperties - possible overrides, can be null
public void onInvalidate(Object key)
throws CacheException
CacheStrategySomeone wants to remove key from the cache. This
strategy can reject the operation by throwing an exception. The actual
removal, if allowed, will be signalled later by a call to this
strategy's onRemove method.
onInvalidate in class CacheStrategycom.vignette.portal.cache.CacheStrategykey - key being removed
public void onInvalidateAll(Collection keys)
throws CacheException
CacheStrategySomeone wants to remove keys from the cache. This
strategy can reject the operation by throwing an exception. The actual
removal, if allowed, will be signalled later by a call to this
strategy's onRemoveAll method.
This is a default implementation. For performance purposes you may wish to override it. If you do, you should not be calling super.onInvalidateAll(Collection).
onInvalidateAll in class CacheStrategycom.vignette.portal.cache.CacheStrategykeys - keys being removed
public void onInvalidateAll()
throws CacheException
CacheStrategySomeone wants to remove all keys from the cache. This strategy can
reject the operation by throwing an exception. The actual removal, if
allowed, will be signalled later by a call to this strategy's
onRemoveAll method.
onInvalidateAll in class CacheStrategy
public void onAdd(Object key,
Object value,
Map properties)
CacheStrategySignals addition to the cache. The mapping of key to
value is being inserted in the cache and this strategy
should start monitoring it, if appropriate for its algorithm.
Individual strategies can use the information in
properties to override their creation-time parameters.
This method should not throw any exception since other strategies on the same cache might already have changed their state in response to this signal and the cache will not be able to revert them back to their prior state. The strategies will become out of sync with each other and with the cache, yielding unpredictable behavior.
Perform any validation checks in onPut instead. But note
that another strategy could call this method without calling
onPut first, in which case there is no way to recover
from invalid conditions.
onAdd in class CacheStrategycom.vignette.portal.cache.CacheStrategykey - key being inserted in the cachevalue - value being inserted in the cache, matching keyproperties - possible overrides, can be null
protected final boolean updateExpirationTime(Object key,
Map properties)
key - the key whose expiration time should be updatedproperties - possible override mappublic void onRemove(Object key)
CacheStrategySignals removal from the cache. The mapping for key is
being removed from the cache and this strategy should stop monitoring
it and clean up, if appropriate for its algorithm.
This method should not throw any exception since other strategies on the same cache might already have changed their state in response to this signal and the cache will not be able to revert them back to their prior state. The strategies will become out of sync with each other and with the cache, yielding unpredictable behavior.
Perform any validation checks in onInvalidate
instead. But note that another strategy could call this method without
calling onInvalidate first, in which case there is no
way to recover from invalid conditions.
onRemove in class CacheStrategycom.vignette.portal.cache.CacheStrategykey - key being removed from the cachepublic void onRemoveAll(Collection keys)
CacheStrategySignals removals from the cache. The mapping for keys
are being removed from the cache and this strategy should stop
monitoring them and clean up, if appropriate for its algorithm.
This method should not throw any exception since other strategies on the same cache might already have changed their state in response to this signal and the cache will not be able to revert them back to their prior state. The strategies will become out of sync with each other and with the cache, yielding unpredictable behavior.
Perform any validation checks in
onInvalidateAll instead. But note
that another strategy could call this method without calling
onInvalidateAll first, in which case
there is no way to recover from invalid conditions.
This is a default implementation. For performance purposes you may wish to override it. If you do, you should not be calling super.onRemoveAll(Collection).
onRemoveAll in class CacheStrategycom.vignette.portal.cache.CacheStrategykeys - keys being removed from the cachepublic void onRemoveAll()
CacheStrategySignals clearing of the cache. All mappings for all keys are being removed from the cache and this strategy should stop monitoring any of them and clean up, if appropriate for its algorithm.
This method should not throw any exception since other strategies on the same cache might already have changed their state in response to this signal and the cache will not be able to revert them back to their prior state. The strategies will become out of sync with each other and with the cache, yielding unpredictable behavior.
Perform any validation checks in
onInvalidateAll instead. But note that another
strategy could call this method without calling
onInvalidateAll first, in which case there is no
way to recover from invalid conditions.
onRemoveAll in class CacheStrategypublic void onPeriod(long now)
onPeriod in interface Periodicalprotected final boolean containsKey(Object key)
|
02/28/2005 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||