org.apache.camel.util
Class LRUWeakCache<K,V>
java.lang.Object
org.apache.camel.util.LRUCache<K,V>
org.apache.camel.util.LRUWeakCache<K,V>
- All Implemented Interfaces:
- com.googlecode.concurrentlinkedhashmap.EvictionListener<K,V>, Serializable, Map<K,V>
public class LRUWeakCache<K,V>
- extends LRUCache<K,V>
A Least Recently Used Cache which uses WeakReference.
This implementation uses WeakReference for stored values in the cache, to support the JVM
when it wants to reclaim objects for example during garbage collection. Therefore this implementation does
not support all the Map methods.
The following methods is only be be used:
- containsKey - To determine if the key is in the cache and refers to a value
- entrySet - To return a set of all the entries (as key/value paris)
- get - To get a value from the cache
- isEmpty - To determine if the cache contains any values
- keySet - To return a set of the current keys which refers to a value
- put - To add a value to the cache
- putAll - To add values to the cache
- remove - To remove a value from the cache by its key
- size - To get the current size
- values - To return a copy of all the value in a list
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.
Notice that if the JVM reclaim memory the content of this cache may be garbage collected, without any
eviction notifications.
- See Also:
LRUCache,
LRUSoftCache,
Serialized Form
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
LRUWeakCache
public LRUWeakCache(int maximumCacheSize)
LRUWeakCache
public LRUWeakCache(int initialCapacity,
int maximumCacheSize)
put
public V put(K key,
V value)
- Specified by:
put in interface Map<K,V>- Overrides:
put in class LRUCache<K,V>
get
public V get(Object o)
- Specified by:
get in interface Map<K,V>- Overrides:
get in class LRUCache<K,V>
putAll
public void putAll(Map<? extends K,? extends V> map)
- Specified by:
putAll in interface Map<K,V>- Overrides:
putAll in class LRUCache<K,V>
remove
public V remove(Object o)
- Specified by:
remove in interface Map<K,V>- Overrides:
remove in class LRUCache<K,V>
values
public Collection<V> values()
- Specified by:
values in interface Map<K,V>- Overrides:
values in class LRUCache<K,V>
size
public int size()
- Specified by:
size in interface Map<K,V>- Overrides:
size in class LRUCache<K,V>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Map<K,V>- Overrides:
isEmpty in class LRUCache<K,V>
containsKey
public boolean containsKey(Object o)
- Specified by:
containsKey in interface Map<K,V>- Overrides:
containsKey in class LRUCache<K,V>
entrySet
public Set<Map.Entry<K,V>> entrySet()
- Specified by:
entrySet in interface Map<K,V>- Overrides:
entrySet in class LRUCache<K,V>
toString
public String toString()
- Overrides:
toString in class LRUCache<K,V>
Apache Camel