|
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
|
+--com.vignette.portal.cache.LeastRecentlyUsedStrategy
Removes the least recently used entries from the cache when the cache's size is being exceeded. This algorithm relies on locality of access to data.
This principle states that a given group of data is either used together or not at all at any given point in time. As you request a piece of data, your next request is very likely to be either for it again, or one of the pieces you requested just prior to it. Therefore, the likelihood of reuse of a piece of data diminishes the further back in time you last accessed it.
This strategy must record the access pattern for all keys and therefore incurs overhead on every call to the cache, thereby reducing its performance.
| Constructor Summary | |
LeastRecentlyUsedStrategy(CacheAction action,
int sizeOfCache)
Creates a cache of specified size with specified action logic. |
|
LeastRecentlyUsedStrategy(int sizeOfCache)
Creates a cache of specified size with default action logic. |
|
| Method Summary | |
void |
onAdd(Object key,
Object value,
Map properties)
Signals addition to the cache. |
void |
onAddAll(Map keyValuePairs,
Map properties)
Signals additions to the cache. |
void |
onGet(Object key,
Map properties)
Someone is accessing key in the Cache. |
protected void |
touch(Object key)
This method should be called when a key is accessed to re-align its usage value. |
| Methods inherited from class com.vignette.portal.cache.SizeBasedStrategy |
getSizeOfCache, onInvalidate, onInvalidateAll, onInvalidateAll, onRemove, onRemoveAll, onRemoveAll |
| Methods inherited from class com.vignette.portal.cache.ActionBasedCacheStrategy |
getCacheAction, setStore |
| Methods inherited from class com.vignette.portal.cache.CacheStrategy |
getStore, onGetAll, onPut, onPutAll |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public LeastRecentlyUsedStrategy(int sizeOfCache)
Creates a cache of specified size with default action logic.
sizeOfCache - the maximum number of objects allowed in the cache.SizeBasedStrategy.SizeBasedStrategy(int)
public LeastRecentlyUsedStrategy(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.SizeBasedStrategy.SizeBasedStrategy(CacheAction, int)| Method Detail |
public void onGet(Object key,
Map properties)
throws CacheException
CacheStrategySomeone is accessing key in the Cache.
Individual strategies can use the information in
properties to override their creation-time parameters.
onGet in class CacheStrategycom.vignette.portal.cache.CacheStrategykey - item being looked upproperties - possible overrides, can be null
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
public void onAddAll(Map keyValuePairs,
Map properties)
CacheStrategySignals additions to the cache. The mappings in
keyValuePairs are being inserted in the cache and this
strategy should start monitoring them, 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 onPutAll instead.
But note that another strategy could call this method without calling
onPutAll 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.onAddAll(Map, Map).
onAddAll in class CacheStrategycom.vignette.portal.cache.CacheStrategykeyValuePairs - key/value pairs being added to the cacheproperties - possible overrides, can be nullprotected final void touch(Object key)
key - the key "touched"
|
02/28/2005 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||