|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.ejb.containers.util.cache.BaseCache
com.sun.ejb.containers.util.cache.LruCache
public class LruCache
LRUCache in-memory bounded cache with an LRU list
| Nested Class Summary | |
|---|---|
protected static class |
LruCache.LruCacheItem
default CacheItem class implementation |
| Nested classes/interfaces inherited from class com.sun.ejb.containers.util.cache.BaseCache |
|---|
BaseCache.CacheItem |
| Field Summary | |
|---|---|
protected static java.util.logging.Logger |
_logger
|
protected java.lang.String |
cacheName
|
protected LruCache.LruCacheItem |
head
|
protected int |
listSize
|
static long |
NO_TIMEOUT
|
protected LruCache.LruCacheItem |
tail
|
protected long |
timeout
|
protected int |
trimCount
|
| Fields inherited from class com.sun.ejb.containers.util.cache.BaseCache |
|---|
_rb, addCount, addCountLk, bucketLocks, buckets, entryCount, entryCountLk, hitCount, hitCountLk, listeners, maxBuckets, missCount, missCountLk, overflowCount, overflowCountLk, refreshCount, refreshCountLk, refreshFlags, removalCount, removalCountLk, threshold |
| Constructor Summary | |
|---|---|
LruCache()
default constructor |
|
LruCache(long timeout)
constructor with specified timeout |
|
| Method Summary | |
|---|---|
protected BaseCache.CacheItem |
createItem(int hashCode,
java.lang.Object key,
java.lang.Object value,
int size)
create new item |
java.lang.Object |
getStatByName(java.lang.String key)
get the desired statistic counter |
java.util.Map |
getStats()
get the stats snapshot |
protected void |
itemAccessed(BaseCache.CacheItem item)
this item is accessed |
protected BaseCache.CacheItem |
itemAdded(BaseCache.CacheItem item)
/** this item is just added to the cache |
protected void |
itemRefreshed(BaseCache.CacheItem item,
int oldSize)
item value has been refreshed |
protected void |
itemRemoved(BaseCache.CacheItem item)
item value has been removed from the cache |
void |
setCacheName(java.lang.String name)
|
void |
trimExpiredEntries(int maxCount)
trim the expired entries from the cache. |
protected BaseCache.CacheItem |
trimLru(long currentTime)
trim one item from the LRU list |
| Methods inherited from class com.sun.ejb.containers.util.cache.BaseCache |
|---|
_put, _remove, _removeItem, add, add, addCacheListener, clear, clearStats, contains, decrementEntryCount, destroy, elements, eq, get, get, getAll, getEntryCount, getIndex, getIndex, handleOverflow, hash, incrementAddCount, incrementEntryCount, incrementHitCount, incrementMissCount, incrementOverflowCount, incrementRefreshCount, incrementRemovalCount, init, init, isEmpty, isThresholdReached, keys, loadValue, notifyRefresh, put, put, remove, remove, remove, removeAll, trimItem, values, waitRefresh |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.util.logging.Logger _logger
protected java.lang.String cacheName
public static final long NO_TIMEOUT
protected LruCache.LruCacheItem head
protected LruCache.LruCacheItem tail
protected int trimCount
protected int listSize
protected long timeout
| Constructor Detail |
|---|
public LruCache()
public LruCache(long timeout)
| Method Detail |
|---|
protected BaseCache.CacheItem createItem(int hashCode,
java.lang.Object key,
java.lang.Object value,
int size)
createItem in class BaseCachehashCode - for the entrykey - Object keyvalue - Object valuesize - size in bytes of the item
subclasses may override to provide their own CacheItem extensions
e.g. one that permits persistence.protected BaseCache.CacheItem trimLru(long currentTime)
currentTime - of this operation
protected BaseCache.CacheItem itemAdded(BaseCache.CacheItem item)
itemAdded in class BaseCacheitem - CacheItem that was created
protected void itemAccessed(BaseCache.CacheItem item)
itemAccessed in class BaseCacheitem - CacheItem accessed
Cache bucket is already synchronized by the caller
protected void itemRefreshed(BaseCache.CacheItem item,
int oldSize)
itemRefreshed in class BaseCacheitem - CacheItem that was refreshedoldSize - size of the previous value that was refreshed
Cache bucket is already synchronized by the callerprotected void itemRemoved(BaseCache.CacheItem item)
itemRemoved in class BaseCacheitem - CacheItem that was just removed
Cache bucket is already synchronized by the callerpublic void trimExpiredEntries(int maxCount)
trimExpiredEntries in interface CachetrimExpiredEntries in class BaseCachemaxCount - maximum number of invalid entries to trim
specify Integer.MAX_VALUE to trim all invalid entries
This call is to be scheduled by a thread managed by the container.
NOTE: this algorithm assumes that all the entries in the cache have
identical timeout (otherwise traversing from tail won't be right).public java.lang.Object getStatByName(java.lang.String key)
getStatByName in interface CachegetStatByName in class BaseCachekey - to corresponding stat
public java.util.Map getStats()
BaseCache
getStats in interface CachegetStats in class BaseCachepublic void setCacheName(java.lang.String name)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||