|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectcom.jdon.cache.UtilCache
public class UtilCache
Generalized caching utility. Provides a number of caching features:
| 字段摘要 | |
|---|---|
Map |
cacheLineTable
A hashtable containing a CacheLine object with a value and a loadTime for each element. for above jdk1.5 |
protected long |
expireTime
Specifies the amount of time since initial loading before an element will be reported as expired. |
protected long |
hitCount
A count of the number of cache hits |
ConcurrentLinkedList |
keyLRUList
A list of the elements order by Least Recent Use |
protected long |
maxSize
The maximum number of elements in the cache. |
protected long |
missCount
A count of the number of cache misses |
static String |
module
|
protected boolean |
useSoftReference
Specifies whether or not to use soft references for this cache, defaults to false |
| 构造方法摘要 | |
|---|---|
UtilCache(int maxSize,
long expireTime,
boolean useSoftReference)
|
|
UtilCache(PropsUtil propsUtil)
Default constructor, all members stay at default values as defined in cache.properties, or the defaults in this file if cache.properties is not found, or there are no 'default' entries in it. |
|
| 方法摘要 | |
|---|---|
void |
clear()
Removes all elements from this cache |
void |
clearAllCaches()
Removes all elements from this cache |
void |
clearCounters()
Clears the hit and miss counters |
void |
clearExpired()
Clears all expired cache entries; also clear any cache entries where the SoftReference in the CacheLine object has been cleared by the gc |
boolean |
containsKey(Object key)
Returns a boolean specifying whether or not an element with the specified key is in the cache. |
Object |
get(Object key)
Gets an element from the cache according to the specified key. |
long |
getExpireTime()
return the current expire time for the cache elements |
long |
getHitCount()
Returns the number of successful hits on the cache |
long |
getMaxSize()
Returns the current maximum number of elements in the cache |
long |
getMissCount()
Returns the number of cache misses |
boolean |
getUseSoftReference()
Return whether or not the cache lines should use a soft reference to the data |
protected boolean |
hasExpired(CacheLine line)
|
boolean |
hasExpired(Object key)
Returns a boolean specifying whether or not the element corresponding to the key has expired. |
Set |
keySet()
|
void |
put(Object key,
Object value)
Puts or loads the passed element into the cache |
void |
remove(Object key)
Removes an element from the cache according to the specified key |
void |
setExpireTime(long expireTime)
Sets the expire time for the cache elements. |
void |
setMaxSize(long maxSize)
Sets the maximum number of elements in the cache. |
protected void |
setPropertiesParams(PropsUtil propsUtil,
String cacheName)
|
long |
size()
Returns the number of elements currently in the cache |
void |
startMon(long expireTime)
|
void |
stop()
|
Collection |
values()
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public static String module
public final ConcurrentLinkedList keyLRUList
public final Map cacheLineTable
protected volatile long hitCount
protected volatile long missCount
protected volatile long maxSize
protected volatile long expireTime
protected volatile boolean useSoftReference
| 构造方法详细信息 |
|---|
public UtilCache(PropsUtil propsUtil)
public UtilCache(int maxSize,
long expireTime,
boolean useSoftReference)
| 方法详细信息 |
|---|
public void startMon(long expireTime)
protected void setPropertiesParams(PropsUtil propsUtil,
String cacheName)
public void put(Object key,
Object value)
key - The key for the element, used to reference it in the hastables
and LRU linked listvalue - The value of the elementpublic Object get(Object key)
key - The key for the element, used to reference it in the hastables
and LRU linked list
public void remove(Object key)
key - The key for the element, used to reference it in the hastables
and LRU linked listpublic Set keySet()
public Collection values()
public void clear()
public void clearAllCaches()
public long getHitCount()
public long getMissCount()
public void clearCounters()
public void setMaxSize(long maxSize)
maxSize - The maximum number of elements in the cachepublic long getMaxSize()
public void setExpireTime(long expireTime)
expireTime - The expire time for the cache elementspublic long getExpireTime()
public boolean getUseSoftReference()
public long size()
public boolean containsKey(Object key)
key - The key for the element, used to reference it in the hastables
and LRU linked list
public boolean hasExpired(Object key)
key - The key for the element, used to reference it in the hastables
and LRU linked list
protected boolean hasExpired(CacheLine line)
public void clearExpired()
public void stop()
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||