org.eclipse.internal.xtend.util
Class WeakCache2<K,V>

java.lang.Object
  extended by org.eclipse.internal.xtend.util.WeakCache2<K,V>
Type Parameters:
K - Key type
V - Value type

public class WeakCache2<K,V>
extends java.lang.Object

A cache implementation based on WeakReferences which cleans up GCed references regularely. Originally copied from URI' internal URICache class.


Field Summary
protected  java.util.Map<K,java.lang.ref.WeakReference<V>> map
           
 
Constructor Summary
WeakCache2()
           
WeakCache2(int min_limit)
           
 
Method Summary
 boolean containsKey(java.lang.String key)
           
 V get(K key)
           
 long getHitCount()
           
 double getHitRatio()
           
 long getMissCount()
           
 long getTotalCount()
           
 void put(K key, V value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected java.util.Map<K,java.lang.ref.WeakReference<V>> map
Constructor Detail

WeakCache2

public WeakCache2()

WeakCache2

public WeakCache2(int min_limit)
Method Detail

get

public V get(K key)

put

public void put(K key,
                V value)

containsKey

public boolean containsKey(java.lang.String key)
Parameters:
key - Cache key
Returns:
true if the cache contains an element with the given key.

getTotalCount

public long getTotalCount()
Returns:
the totalCount

getHitCount

public long getHitCount()
Returns:
the hitCount

getMissCount

public long getMissCount()

getHitRatio

public double getHitRatio()