02/28/2005
 

com.vignette.portal.cache
Class HardLeastRecentlyUsedStrategy

java.lang.Object
  |
  +--com.vignette.portal.cache.CacheStrategy
        |
        +--com.vignette.portal.cache.ActionBasedCacheStrategy
              |
              +--com.vignette.portal.cache.SizeBasedStrategy
                    |
                    +--com.vignette.portal.cache.LeastRecentlyUsedStrategy
                          |
                          +--com.vignette.portal.cache.HardLeastRecentlyUsedStrategy

public class HardLeastRecentlyUsedStrategy
extends LeastRecentlyUsedStrategy

Makes sure the size threshold is never exceeded.

This strategy checks the size boundary every time something is added to the cache and therefore has high everhead. In addition, by aggressively removing contents from the cache, it lowers the hit ratio and may trigger more database accesses than a less aggressive strategy.

See Also:
SoftLeastRecentlyUsedStrategy

Constructor Summary
HardLeastRecentlyUsedStrategy(CacheAction action, int sizeOfCache)
          Creates a cache of specified size with specified action logic.
HardLeastRecentlyUsedStrategy(int sizeOfCache)
          Creates a cache of specified size with default action logic.
 
Method Summary
 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.
 
Methods inherited from class com.vignette.portal.cache.LeastRecentlyUsedStrategy
onAdd, onAddAll, onGet, touch
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HardLeastRecentlyUsedStrategy

public HardLeastRecentlyUsedStrategy(int sizeOfCache)

Creates a cache of specified size with default action logic.

Parameters:
sizeOfCache - the maximum number of objects allowed in the cache.
See Also:
LeastRecentlyUsedStrategy.LeastRecentlyUsedStrategy(int)

HardLeastRecentlyUsedStrategy

public HardLeastRecentlyUsedStrategy(CacheAction action,
                                     int sizeOfCache)

Creates a cache of specified size with specified action logic.

Parameters:
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.
See Also:
LeastRecentlyUsedStrategy.LeastRecentlyUsedStrategy(CacheAction, int)
Method Detail

onPut

public void onPut(Object key,
                  Object value,
                  Map properties)
           throws CacheException
Description copied from class: CacheStrategy

Someone 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.

Overrides:
onPut in class CacheStrategy
Following copied from class: com.vignette.portal.cache.CacheStrategy
Parameters:
key - key being added
value - value being added, matching key
properties - possible overrides, can be null

onPutAll

public void onPutAll(Map keyValuePairs,
                     Map properties)
              throws CacheException
Description copied from class: CacheStrategy

Someone 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).

Overrides:
onPutAll in class CacheStrategy
Following copied from class: com.vignette.portal.cache.CacheStrategy
Parameters:
keyValuePairs - key/value pairs being added
properties - possible overrides, can be null

02/28/2005
 

Copyright and Trademark Notices