|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
org.apache.camel.util.LRUCache<K,V>
public class LRUCache<K,V>
A Least Recently Used Cache
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
Constructor Summary | |
---|---|
LRUCache(int maximumCacheSize)
|
|
LRUCache(int initialCapacity,
int maximumCacheSize,
float loadFactor,
boolean accessOrder)
Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode. |
Method Summary | |
---|---|
V |
get(Object o)
|
long |
getHits()
Gets the number of cache hits |
int |
getMaxCacheSize()
Returns the maxCacheSize. |
long |
getMisses()
Gets the number of cache misses. |
protected boolean |
removeEldestEntry(Map.Entry<K,V> entry)
|
void |
resetStatistics()
Rest the cache statistics such as hits and misses. |
void |
start()
Starts the service |
void |
stop()
Stops the service |
String |
toString()
|
Methods inherited from class java.util.LinkedHashMap |
---|
clear, containsValue |
Methods inherited from class java.util.HashMap |
---|
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
containsKey, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Constructor Detail |
---|
public LRUCache(int maximumCacheSize)
public LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder)
initialCapacity
- the initial capacity.maximumCacheSize
- the max capacity.loadFactor
- the load factor.accessOrder
- the ordering mode - true for
access-order, false for insertion-order.
IllegalArgumentException
- if the initial capacity is negative
or the load factor is non positive.Method Detail |
---|
public V get(Object o)
get
in interface Map<K,V>
get
in class LinkedHashMap<K,V>
public long getHits()
public long getMisses()
public int getMaxCacheSize()
public void resetStatistics()
protected boolean removeEldestEntry(Map.Entry<K,V> entry)
removeEldestEntry
in class LinkedHashMap<K,V>
public void start() throws Exception
Service
start
in interface Service
Exception
- is thrown if starting failedpublic void stop() throws Exception
Service
stop
in interface Service
Exception
- is thrown if stopping failedpublic String toString()
toString
in class AbstractMap<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |