02/28/2005
 

com.vignette.portal.cache
Class SoftLeastRecentlyUsedStrategy

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.SoftLeastRecentlyUsedStrategy
All Implemented Interfaces:
Periodical

public class SoftLeastRecentlyUsedStrategy
extends LeastRecentlyUsedStrategy
implements Periodical

Periodically checks that the size threshold is not exceeded.

This strategy implements the Periodical interface and checks the size boundary as part of its SoftLeastRecentlyUsedStrategy.onPeriod(long) method. Between periods, the cache is allowed to grow in an unbounded fashion and gets trimmed at the following periodical check. Its overhead is lower that some of the more aggressive strategies, but it has a potential for overrunning the memory.

See Also:
HardLeastRecentlyUsedStrategy

Constructor Summary
SoftLeastRecentlyUsedStrategy(CacheAction action, int sizeOfCache)
          Creates a cache of specified size with specified action logic.
SoftLeastRecentlyUsedStrategy(int sizeOfCache)
          Creates a cache of specified size with default action logic.
 
Method Summary
 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.
 
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

SoftLeastRecentlyUsedStrategy

public SoftLeastRecentlyUsedStrategy(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)

SoftLeastRecentlyUsedStrategy

public SoftLeastRecentlyUsedStrategy(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

onPeriod

public void onPeriod(long now)
Specified by:
onPeriod in interface Periodical

02/28/2005
 

Copyright and Trademark Notices