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 long
currentSize
protected long
maxSize
-
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 void
decrementCurrentSize(int size)
Object
getStatByName(String key)
get the desired statistic counterMap
getStats()
get the stats snapshotprotected void
incrementCurrentSize(int size)
synchronized counter updatesvoid
init(int maxCapacity, Properties props)
initialize the LRU cacheprotected boolean
isThresholdReached()
has cache reached its thresholdprotected BaseCache.CacheItem
itemAdded(BaseCache.CacheItem item)
this item is just added to the cacheprotected void
itemRefreshed(BaseCache.CacheItem item, int oldSize)
item value has been refreshedprotected void
itemRemoved(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 Exception
initialize the LRU cache- Specified by:
init
in interfaceCache
- Overrides:
init
in 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:
itemAdded
in classMultiLruCache
- Parameters:
item
-CacheItem
that 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:
itemRefreshed
in classMultiLruCache
- Parameters:
item
-CacheItem
that 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:
itemRemoved
in classMultiLruCache
- Parameters:
item
-CacheItem
that was just removed Cache bucket is already synchronized by the caller
-
isThresholdReached
protected boolean isThresholdReached()
has cache reached its threshold- Overrides:
isThresholdReached
in 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:
getStatByName
in interfaceCache
- Overrides:
getStatByName
in 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:MultiLruCache
get the stats snapshot- Specified by:
getStats
in interfaceCache
- Overrides:
getStats
in classMultiLruCache
- Returns:
- a Map of stats See also: Constant.java for the keys
-
-