org.apache.camel.util
Class LRUCache<K,V>

java.lang.Object
  extended by org.apache.camel.util.LRUCache<K,V>
All Implemented Interfaces:
java.io.Serializable, java.util.Map<K,V>
Direct Known Subclasses:
LRUSoftCache

public class LRUCache<K,V>
extends java.lang.Object
implements java.util.Map<K,V>, java.io.Serializable

A Least Recently Used Cache

Version:
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
LRUCache(int maximumCacheSize)
           
LRUCache(int initialCapacity, int maximumCacheSize)
          Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object o)
           
 boolean containsValue(java.lang.Object o)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 V get(java.lang.Object o)
           
 long getHits()
          Gets the number of cache hits
 int getMaxCacheSize()
          Returns the maxCacheSize.
 long getMisses()
          Gets the number of cache misses.
 boolean isEmpty()
           
 java.util.Set<K> keySet()
           
 V put(K k, V v)
           
 void putAll(java.util.Map<? extends K,? extends V> map)
           
 V remove(java.lang.Object o)
           
 void resetStatistics()
          Rest the cache statistics such as hits and misses.
 int size()
           
 java.lang.String toString()
           
 java.util.Collection<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

LRUCache

public LRUCache(int maximumCacheSize)

LRUCache

public LRUCache(int initialCapacity,
                int maximumCacheSize)
Constructs an empty LRUCache instance with the specified initial capacity, maximumCacheSize,load factor and ordering mode.

Parameters:
initialCapacity - the initial capacity.
maximumCacheSize - the max capacity.
Throws:
java.lang.IllegalArgumentException - if the initial capacity is negative or the load factor is non positive.
Method Detail

get

public V get(java.lang.Object o)
Specified by:
get in interface java.util.Map<K,V>

size

public int size()
Specified by:
size in interface java.util.Map<K,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<K,V>

containsKey

public boolean containsKey(java.lang.Object o)
Specified by:
containsKey in interface java.util.Map<K,V>

containsValue

public boolean containsValue(java.lang.Object o)
Specified by:
containsValue in interface java.util.Map<K,V>

put

public V put(K k,
             V v)
Specified by:
put in interface java.util.Map<K,V>

remove

public V remove(java.lang.Object o)
Specified by:
remove in interface java.util.Map<K,V>

putAll

public void putAll(java.util.Map<? extends K,? extends V> map)
Specified by:
putAll in interface java.util.Map<K,V>

clear

public void clear()
Specified by:
clear in interface java.util.Map<K,V>

keySet

public java.util.Set<K> keySet()
Specified by:
keySet in interface java.util.Map<K,V>

values

public java.util.Collection<V> values()
Specified by:
values in interface java.util.Map<K,V>

entrySet

public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,V>

getHits

public long getHits()
Gets the number of cache hits


getMisses

public long getMisses()
Gets the number of cache misses.


getMaxCacheSize

public int getMaxCacheSize()
Returns the maxCacheSize.


resetStatistics

public void resetStatistics()
Rest the cache statistics such as hits and misses.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Apache CAMEL