|
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.SizeBasedStrategy
Keeps the number of entries in the cache below a given threshold. It removes elements when it detects that the size limit is being exceeded. Subclasses implement specific algorithms for selecting which elements to onRemove and when to check the size boundary.
| Constructor Summary | |
SizeBasedStrategy(CacheAction action,
int sizeOfCache)
Creates a cache of specified size with specified action logic. |
|
SizeBasedStrategy(int sizeOfCache)
Creates a cache of specified size with default action logic. |
|
| Method Summary | |
protected int |
getSizeOfCache()
|
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 |
onRemove(Object key)
Signals removal from the cache. |
void |
onRemoveAll()
Signals clearing of the cache. |
void |
onRemoveAll(Collection keys)
Signals removals from the cache. |
| Methods inherited from class com.vignette.portal.cache.ActionBasedCacheStrategy |
getCacheAction, setStore |
| Methods inherited from class com.vignette.portal.cache.CacheStrategy |
getStore, onAdd, onAddAll, onGet, onGetAll, onPut, onPutAll |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SizeBasedStrategy(int sizeOfCache)
Creates a cache of specified size with default action logic.
sizeOfCache - the maximum number of objects allowed in the cache.ActionBasedCacheStrategy.ActionBasedCacheStrategy()
public SizeBasedStrategy(CacheAction action,
int sizeOfCache)
Creates a cache of specified size with specified action logic.
action - the non-null action to invoke when the size of the cache is exceeded.sizeOfCache - the maximum number of objects allowed in the cache.ActionBasedCacheStrategy.ActionBasedCacheStrategy(CacheAction)| Method Detail |
protected int getSizeOfCache()
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 CacheStrategypublic 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 CacheStrategy
|
02/28/2005 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||