K
- The key of the cacheV
- The values in the cachepublic class LRUCacheCheapRead<K,V> extends LRUCache<K,V>
Modifier and Type | Class and Description |
---|---|
private static class |
LRUCacheCheapRead.CacheEntryImpl<K,V> |
private static class |
LRUCacheCheapRead.CacheEntryImplComparator |
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Map<K,LRUCacheCheapRead.CacheEntryImpl<K,V>> |
cache |
private static LRUCacheCheapRead.CacheEntryImplComparator |
COMPARATOR |
(package private) int |
maxCacheSize |
(package private) java.lang.Object |
prunningLock |
Constructor and Description |
---|
LRUCacheCheapRead(int maxCacheSize)
Create new cache with given maximum capacity.
|
Modifier and Type | Method and Description |
---|---|
V |
get(K key)
Returns the value associated with the given key.
|
int |
getMaxCacheSize()
Returns the maximum number of entries that will be stored in this cache
|
CacheEntry |
put(K key,
V value)
Adds the given key and value pair into the cache
|
void |
releaseCache()
Clears all entries in the cache, for use when a known event makes the cache incorrect
|
void |
releaseMatching(CacheKeyFilter<K> filter)
This method will remove all cache entries for which this filter
matches
|
private void |
removeLRUItem()
Remove least recently used item form the cache.
|
createCache
final java.lang.Object prunningLock
final int maxCacheSize
java.util.Map<K,LRUCacheCheapRead.CacheEntryImpl<K,V>> cache
private static final LRUCacheCheapRead.CacheEntryImplComparator COMPARATOR
public LRUCacheCheapRead(int maxCacheSize)
maxCacheSize
- Maximum number of items to keep.public V get(K key)
LRUCache
public CacheEntry put(K key, V value)
LRUCache
public void releaseCache()
LRUCache
releaseCache
in class LRUCache<K,V>
public int getMaxCacheSize()
LRUCache
getMaxCacheSize
in class LRUCache<K,V>
public void releaseMatching(CacheKeyFilter<K> filter)
LRUCache
releaseMatching
in class LRUCache<K,V>
filter
- Entries in the cache that match this filter will
be removed from the cache. If filter is null nothing
will be removed from the cacheprivate void removeLRUItem()