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
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
FieldsFields inherited from class com.sun.appserv.util.cache.MultiLruCache
DEFAULT_HASHTABLE_SEGMENT_SIZE, listsLength, LRU_HEAD, LRU_TAILFields inherited from class com.sun.appserv.util.cache.BaseCache
bucketLocks, buckets, entryCount, hitCount, listeners, maxBuckets, maxEntries, missCount, refreshFlags, removalCount, threshold -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voiddecrementCurrentSize(int size) getStatByName(String key) get the desired statistic countergetStats()get the stats snapshotprotected final voidincrementCurrentSize(int size) synchronized counter updatesvoidinit(int maxCapacity, Properties props) initialize the LRU cacheprotected booleanhas 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 voiditem value has been removed from the cacheMethods inherited from class com.sun.appserv.util.cache.MultiLruCache
createItem, handleOverflow, incrementTrimIndex, itemAccessed, trimLruMethods 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
-
Field Details
-
maxSize
protected long maxSize -
currentSize
protected long currentSize
-
-
Constructor Details
-
BoundedMultiLruCache
public BoundedMultiLruCache()
-
-
Method Details
-
init
initialize 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
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
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
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
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
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
-