class MemoryCache<K,V> extends Cache<K,V>
| 限定符和类型 | 类和说明 |
|---|---|
private static interface |
MemoryCache.CacheEntry<K,V> |
private static class |
MemoryCache.HardCacheEntry<K,V> |
private static class |
MemoryCache.SoftCacheEntry<K,V> |
Cache.CacheVisitor<K,V>, Cache.EqualByteArray| 限定符和类型 | 字段和说明 |
|---|---|
private Map<K,MemoryCache.CacheEntry<K,V>> |
cacheMap |
private static boolean |
DEBUG |
private long |
lifetime |
private static float |
LOAD_FACTOR |
private int |
maxSize |
private long |
nextExpirationTime |
private ReferenceQueue<V> |
queue |
| 构造器和说明 |
|---|
MemoryCache(boolean soft,
int maxSize) |
MemoryCache(boolean soft,
int maxSize,
int lifetime) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
accept(Cache.CacheVisitor<K,V> visitor)
accept a visitor
|
void |
clear()
Remove all entries from the cache.
|
private void |
emptyQueue()
Empty the reference queue and remove all corresponding entries
from the cache.
|
private void |
expungeExpiredEntries()
Scan all entries and remove all expired ones.
|
V |
get(Object key)
Get a value from the cache.
|
private Map<K,V> |
getCachedEntries() |
protected MemoryCache.CacheEntry<K,V> |
newEntry(K key,
V value,
long expirationTime,
ReferenceQueue<V> queue) |
V |
pull(Object key)
Pull an entry from the cache.
|
void |
put(K key,
V value)
Add an entry to the cache.
|
void |
remove(Object key)
Remove an entry from the cache.
|
void |
setCapacity(int size)
Set the maximum size.
|
void |
setTimeout(int timeout)
Set the timeout(in seconds).
|
int |
size()
Return the number of currently valid entries in the cache.
|
newHardMemoryCache, newHardMemoryCache, newNullCache, newSoftMemoryCache, newSoftMemoryCacheprivate static final float LOAD_FACTOR
private static final boolean DEBUG
private final Map<K,MemoryCache.CacheEntry<K,V>> cacheMap
private int maxSize
private long lifetime
private long nextExpirationTime
private final ReferenceQueue<V> queue
public MemoryCache(boolean soft,
int maxSize)
public MemoryCache(boolean soft,
int maxSize,
int lifetime)
private void emptyQueue()
private void expungeExpiredEntries()
public int size()
Cachepublic void clear()
Cachepublic void setCapacity(int size)
CachesetCapacity 在类中 Cache<K,V>public void setTimeout(int timeout)
CachesetTimeout 在类中 Cache<K,V>public void accept(Cache.CacheVisitor<K,V> visitor)
Cacheprotected MemoryCache.CacheEntry<K,V> newEntry(K key, V value, long expirationTime, ReferenceQueue<V> queue)
Copyright © 2023. All rights reserved.