public class LRUCache<K,V> extends Object implements Map<K,V>, com.googlecode.concurrentlinkedhashmap.EvictionListener<K,V>, Serializable
Service
then this implementation will on eviction
invoke the Service.stop()
method, to auto-stop the service.LRUSoftCache
,
LRUWeakCache
,
Serialized FormConstructor and Description |
---|
LRUCache(int maximumCacheSize)
Constructs an empty LRUCache instance with the
specified maximumCacheSize, and will stop on eviction.
|
LRUCache(int initialCapacity,
int maximumCacheSize)
Constructs an empty LRUCache instance with the
specified initial capacity, maximumCacheSize, and will stop on eviction.
|
LRUCache(int initialCapacity,
int maximumCacheSize,
boolean stopOnEviction)
Constructs an empty LRUCache instance with the
specified initial capacity, maximumCacheSize,load factor and ordering mode.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object o) |
boolean |
containsValue(Object o) |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object o) |
long |
getEvicted()
Gets the number of evicted entries.
|
long |
getHits()
Gets the number of cache hits
|
int |
getMaxCacheSize()
Returns the maxCacheSize.
|
long |
getMisses()
Gets the number of cache misses.
|
boolean |
isEmpty() |
Set<K> |
keySet() |
void |
onEviction(K key,
V value) |
V |
put(K k,
V v) |
void |
putAll(Map<? extends K,? extends V> map) |
V |
remove(Object o) |
void |
resetStatistics()
Rest the cache statistics such as hits and misses.
|
int |
size() |
String |
toString() |
Collection<V> |
values() |
public LRUCache(int maximumCacheSize)
maximumCacheSize
- the max capacity.IllegalArgumentException
- if the initial capacity is negativepublic LRUCache(int initialCapacity, int maximumCacheSize)
initialCapacity
- the initial capacity.maximumCacheSize
- the max capacity.IllegalArgumentException
- if the initial capacity is negativepublic LRUCache(int initialCapacity, int maximumCacheSize, boolean stopOnEviction)
initialCapacity
- the initial capacity.maximumCacheSize
- the max capacity.stopOnEviction
- whether to stop service on eviction.IllegalArgumentException
- if the initial capacity is negativepublic boolean containsKey(Object o)
containsKey
in interface Map<K,V>
public boolean containsValue(Object o)
containsValue
in interface Map<K,V>
public void onEviction(K key, V value)
public long getHits()
public long getMisses()
public long getEvicted()
public int getMaxCacheSize()
public void resetStatistics()
Apache Camel