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

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

public class LRUSoftCache<K,V>
extends LRUCache<K,V>

A Least Recently Used Cache which uses SoftReference.

This implementation uses SoftReference for stored values in the cache, to support the JVM when it wants to reclaim objects when its running out of memory. Therefore this implementation does not support all the Map methods.

The following methods is only be be used:

The LRUCache.containsValue(Object) method should not be used as it's not adjusted to check for the existence of a value without catering for the soft references.

See Also:
LRUCache, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
LRUSoftCache(int maximumCacheSize)
           
LRUSoftCache(int initialCapacity, int maximumCacheSize)
           
 
Method Summary
 boolean containsKey(java.lang.Object o)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 V get(java.lang.Object o)
           
 boolean isEmpty()
           
 V put(K key, V value)
           
 void putAll(java.util.Map<? extends K,? extends V> map)
           
 V remove(java.lang.Object o)
           
 int size()
           
 java.lang.String toString()
           
 java.util.Collection<V> values()
           
 
Methods inherited from class org.apache.camel.util.LRUCache
clear, containsValue, getHits, getMaxCacheSize, getMisses, keySet, resetStatistics
 
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

LRUSoftCache

public LRUSoftCache(int maximumCacheSize)

LRUSoftCache

public LRUSoftCache(int initialCapacity,
                    int maximumCacheSize)
Method Detail

put

public V put(K key,
             V value)
Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class LRUCache<K,V>

get

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

putAll

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

remove

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

values

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

size

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

isEmpty

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

containsKey

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

entrySet

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

toString

public java.lang.String toString()
Overrides:
toString in class LRUCache<K,V>


Apache CAMEL