org.tinygroup.jspengine.appserv.util.cache
类 LruCache

java.lang.Object
  继承者 org.tinygroup.jspengine.appserv.util.cache.BaseCache
      继承者 org.tinygroup.jspengine.appserv.util.cache.LruCache
所有已实现的接口:
Cache

public class LruCache
extends BaseCache

LRUCache in-memory bounded cache with an LRU list


嵌套类摘要
protected static class LruCache.LruCacheItem
          default CacheItem class implementation
 
从类 org.tinygroup.jspengine.appserv.util.cache.BaseCache 继承的嵌套类/接口
BaseCache.CacheItem
 
字段摘要
protected  int defaultMaxEntries
           
protected  LruCache.LruCacheItem head
           
protected  boolean isUnbounded
           
protected  int listSize
           
static long NO_TIMEOUT
           
protected  LruCache.LruCacheItem tail
           
protected  long timeout
           
protected  int trimCount
           
 
从类 org.tinygroup.jspengine.appserv.util.cache.BaseCache 继承的字段
_rb, bucketLocks, buckets, entryCount, listeners, maxBuckets, refreshFlags, threshold
 
构造方法摘要
LruCache()
          default constructor
LruCache(int defaultMaxEntries)
          constructor with specified max entries.
 
方法摘要
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
 void init(int maxEntries, long timeout, float loadFactor, Properties props)
          initialize the 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
 void setTimeout(long timeout)
          sets the timeout value
 void trimExpiredEntries(int maxCount)
          trim the expired entries from the cache.
protected  BaseCache.CacheItem trimLru(long currentTime)
          trim one item from the LRU list
 
从类 org.tinygroup.jspengine.appserv.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
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

NO_TIMEOUT

public static final long NO_TIMEOUT
另请参见:
常量字段值

head

protected LruCache.LruCacheItem head

tail

protected LruCache.LruCacheItem tail

trimCount

protected int trimCount

listSize

protected int listSize

timeout

protected long timeout

defaultMaxEntries

protected int defaultMaxEntries

isUnbounded

protected boolean isUnbounded
构造方法详细信息

LruCache

public LruCache()
default constructor


LruCache

public LruCache(int defaultMaxEntries)
constructor with specified max entries.

参数:
defaultMaxEntries - specifies the default max entries to use when the maxEntries is <= 0.
方法详细信息

init

public void init(int maxEntries,
                 long timeout,
                 float loadFactor,
                 Properties props)
initialize the cache

参数:
maxEntries - maximum number of entries expected in the cache
loadFactor - the load factor
timeout - to be used to trim the expired entries
props - opaque list of properties for a given cache implementation
抛出:
a - generic Exception if the initialization failed

setTimeout

public void setTimeout(long timeout)
sets the timeout value

参数:
timeout - to be used to trim the expired entries

createItem

protected BaseCache.CacheItem createItem(int hashCode,
                                         Object key,
                                         Object value,
                                         int size)
create new item

覆盖:
BaseCache 中的 createItem
参数:
hashCode - for the entry
key - Object key
value - Object value
size - size in bytes of the item subclasses may override to provide their own CacheItem extensions e.g. one that permits persistence.

trimLru

protected BaseCache.CacheItem trimLru(long currentTime)
trim one item from the LRU list

参数:
currentTime - of this operation
返回:
the item trimmed from cache list synchronization is handled by the caller

itemAdded

protected BaseCache.CacheItem itemAdded(BaseCache.CacheItem item)
/** this item is just added to the cache

覆盖:
BaseCache 中的 itemAdded
参数:
item - CacheItem that was created
返回:
a overflow item; may be null this function checks if adding the new item results in a overflow; if so, it returns the item to be removed. Cache bucket is already synchronized by the caller

itemAccessed

protected void itemAccessed(BaseCache.CacheItem item)
this item is accessed

覆盖:
BaseCache 中的 itemAccessed
参数:
item - CacheItem accessed Cache bucket is already synchronized by the caller

itemRefreshed

protected void itemRefreshed(BaseCache.CacheItem item,
                             int oldSize)
item value has been refreshed

覆盖:
BaseCache 中的 itemRefreshed
参数:
item - CacheItem that was refreshed
oldSize - 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

覆盖:
BaseCache 中的 itemRemoved
参数:
item - CacheItem that was just removed Cache bucket is already synchronized by the caller

trimExpiredEntries

public void trimExpiredEntries(int maxCount)
trim the expired entries from the cache.

指定者:
接口 Cache 中的 trimExpiredEntries
覆盖:
BaseCache 中的 trimExpiredEntries
参数:
maxCount - 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).

getStatByName

public Object getStatByName(String key)
get the desired statistic counter

指定者:
接口 Cache 中的 getStatByName
覆盖:
BaseCache 中的 getStatByName
参数:
key - to corresponding stat
返回:
an Object corresponding to the stat See also: Constant.java for the key

getStats

public Map getStats()
从类 BaseCache 复制的描述
get the stats snapshot

指定者:
接口 Cache 中的 getStats
覆盖:
BaseCache 中的 getStats
返回:
a Map of stats See also: Constant.java for the keys


Copyright © 2006–2014 开源组织. All rights reserved.