public class MultiLruCache extends BaseCache
BaseCache.CacheItem
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_HASHTABLE_SEGMENT_SIZE |
protected int[] |
listsLength |
static int |
LRU_HEAD |
static int |
LRU_TAIL |
_rb, bucketLocks, buckets, entryCount, listeners, maxBuckets, refreshFlags, threshold
Constructor and Description |
---|
MultiLruCache() |
Modifier and Type | Method and Description |
---|---|
protected BaseCache.CacheItem |
createItem(int hashCode,
Object key,
Object value,
int size)
create new item
|
Object |
getStatByName(String key)
get the desired statistic counter
|
Map |
getStats()
get the stats snapshot
|
protected void |
handleOverflow()
cache has reached threshold so trim its size.
|
protected void |
incrementTrimIndex() |
void |
init(int maxCapacity,
Properties props)
initialize the LRU cache
|
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
|
protected BaseCache.CacheItem |
trimLru(int segment)
remove an lru item from one of the LRU lists
|
_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, isThresholdReached, keys, loadValue, notifyRefresh, put, put, remove, remove, remove, removeAll, trimExpiredEntries, trimItem, values, waitRefresh
public static final int LRU_HEAD
public static final int LRU_TAIL
public static final int DEFAULT_HASHTABLE_SEGMENT_SIZE
protected int[] listsLength
public void init(int maxCapacity, Properties props) throws Exception
protected BaseCache.CacheItem createItem(int hashCode, Object key, Object value, int size)
createItem
in class BaseCache
hashCode
- 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(int segment)
the
- LRU segment index to trimprotected BaseCache.CacheItem itemAdded(BaseCache.CacheItem item)
protected void itemAccessed(BaseCache.CacheItem item)
itemAccessed
in class BaseCache
item
- CacheItem
accessed
Cache bucket is already synchronized by the caller
protected void itemRefreshed(BaseCache.CacheItem item, int oldSize)
itemRefreshed
in class BaseCache
item
- 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 BaseCache
item
- CacheItem
that was just removed
Cache bucket is already synchronized by the caller
protected void handleOverflow()
handleOverflow
in class BaseCache
protected void incrementTrimIndex()
public Object getStatByName(String key)
getStatByName
in interface Cache
getStatByName
in class BaseCache
key
- to corresponding statCopyright © 2006–2018 TinyGroup. All rights reserved.