Package com.sun.appserv.util.cache
Class BoundedMultiLruCache
- java.lang.Object
-
- com.sun.appserv.util.cache.BaseCache
-
- com.sun.appserv.util.cache.MultiLruCache
-
- com.sun.appserv.util.cache.BoundedMultiLruCache
-
- All Implemented Interfaces:
Cache
public class BoundedMultiLruCache extends MultiLruCache
MultiLruCache -- in-memory bounded LRU cache with multiple LRU lists Underlying Hashtable is made into logical segments, with each segment having its own LRU list.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.sun.appserv.util.cache.BaseCache
BaseCache.CacheItem
-
-
Field Summary
Fields Modifier and Type Field Description protected longcurrentSizeprotected longmaxSize-
Fields inherited from class com.sun.appserv.util.cache.MultiLruCache
DEFAULT_HASHTABLE_SEGMENT_SIZE, listsLength, LRU_HEAD, LRU_TAIL
-
Fields inherited from class com.sun.appserv.util.cache.BaseCache
bucketLocks, buckets, entryCount, hitCount, listeners, maxBuckets, maxEntries, missCount, refreshFlags, removalCount, threshold
-
-
Constructor Summary
Constructors Constructor Description BoundedMultiLruCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddecrementCurrentSize(int size)ObjectgetStatByName(String key)get the desired statistic counterMapgetStats()get the stats snapshotprotected voidincrementCurrentSize(int size)synchronized counter updatesvoidinit(int maxCapacity, Properties props)initialize the LRU cacheprotected booleanisThresholdReached()has cache reached its thresholdprotected BaseCache.CacheItemitemAdded(BaseCache.CacheItem item)this item is just added to the cacheprotected voiditemRefreshed(BaseCache.CacheItem item, int oldSize)item value has been refreshedprotected voiditemRemoved(BaseCache.CacheItem item)item value has been removed from the cache-
Methods inherited from class com.sun.appserv.util.cache.MultiLruCache
createItem, handleOverflow, incrementTrimIndex, itemAccessed, trimLru
-
Methods inherited from class com.sun.appserv.util.cache.BaseCache
_put, _remove, _removeItem, add, add, addCacheListener, clear, clearStats, contains, decrementEntryCount, destroy, elements, eq, get, get, getAll, getEntryCount, getIndex, getIndex, hash, incrementAddCount, incrementEntryCount, incrementHitCount, incrementMissCount, incrementOverflowCount, incrementRefreshCount, incrementRemovalCount, init, isEmpty, keys, loadValue, notifyRefresh, put, put, remove, remove, remove, removeAll, trimExpiredEntries, trimItem, values, waitRefresh
-
-
-
-
Method Detail
-
init
public void init(int maxCapacity, Properties props) throws Exceptioninitialize the LRU cache- Specified by:
initin interfaceCache- Overrides:
initin classMultiLruCache- Parameters:
maxCapacity- maximum number of entries this cache may holdprops- opaque list of properties for a given cache implementation- Throws:
Exception
-
itemAdded
protected BaseCache.CacheItem itemAdded(BaseCache.CacheItem item)
this item is just added to the cache- Overrides:
itemAddedin classMultiLruCache- Parameters:
item-CacheItemthat was created- Returns:
- a overflow item; may be null Cache bucket is already synchronized by the caller
-
itemRefreshed
protected void itemRefreshed(BaseCache.CacheItem item, int oldSize)
item value has been refreshed- Overrides:
itemRefreshedin classMultiLruCache- Parameters:
item-CacheItemthat was refreshedoldSize- size of the previous value that was refreshed Cache bucket is already synchronized by the caller
-
itemRemoved
protected void itemRemoved(BaseCache.CacheItem item)
item value has been removed from the cache- Overrides:
itemRemovedin classMultiLruCache- Parameters:
item-CacheItemthat was just removed Cache bucket is already synchronized by the caller
-
isThresholdReached
protected boolean isThresholdReached()
has cache reached its threshold- Overrides:
isThresholdReachedin classBaseCache- Returns:
- true when the cache reached its threshold
-
incrementCurrentSize
protected final void incrementCurrentSize(int size)
synchronized counter updates
-
decrementCurrentSize
protected final void decrementCurrentSize(int size)
-
getStatByName
public Object getStatByName(String key)
get the desired statistic counter- Specified by:
getStatByNamein interfaceCache- Overrides:
getStatByNamein classMultiLruCache- Parameters:
key- to corresponding stat- Returns:
- an Object corresponding to the stat See also: Constant.java for the key
-
getStats
public Map getStats()
Description copied from class:MultiLruCacheget the stats snapshot- Specified by:
getStatsin interfaceCache- Overrides:
getStatsin classMultiLruCache- Returns:
- a Map of stats See also: Constant.java for the keys
-
-