Class MaxCacheSizePolicy<K,V>
- java.lang.Object
-
- edu.uiuc.ncsa.security.core.cache.MaxCacheSizePolicy<K,V>
-
- All Implemented Interfaces:
RetentionPolicy
public class MaxCacheSizePolicy<K,V> extends Object implements RetentionPolicy
The retention policy forCreated by Jeff Gaynor
on Nov 12, 2010 at 9:51:36 AM
-
-
Constructor Summary
Constructors Constructor Description MaxCacheSizePolicy(Map<K,V> cache, int maxCacheSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapplies()If this applies to the current cache.Map<K,V>getMap()The cache to which this policy is applied.intgetMaximumSize()booleanretain(Object key, Object value)voidsetMap(Map<K,V> map)voidsetMaximumSize(int maximumSize)protected booleansizeOk()Returns true if the size of the cache is ok.
-
-
-
Method Detail
-
getMap
public Map<K,V> getMap()
Description copied from interface:RetentionPolicyThe cache to which this policy is applied.- Specified by:
getMapin interfaceRetentionPolicy<K,V>- Returns:
-
getMaximumSize
public int getMaximumSize()
-
setMaximumSize
public void setMaximumSize(int maximumSize)
-
retain
public boolean retain(Object key, Object value)
- Specified by:
retainin interfaceRetentionPolicy<K,V>
-
applies
public boolean applies()
Description copied from interface:RetentionPolicyIf this applies to the current cache. While this is true, theRetentionPolicy.retain(Object, Object)method will be applied to each element of the cache. When false, this policy will be skipped.
E.g. for a cache that limits the number of cached items, there is no reason to check every item in the cache directly if the cache size is below a certain threshold.- Specified by:
appliesin interfaceRetentionPolicy<K,V>- Returns:
-
sizeOk
protected boolean sizeOk()
Returns true if the size of the cache is ok.- Returns:
-
-