Package org.python.core.util
Class LimitedCache<K,V>
- java.lang.Object
-
- org.python.core.util.LimitedCache<K,V>
-
public class LimitedCache<K,V> extends java.lang.Object
Not for application use, a cache of recently given results from some costly function. This is only public so we can reach it from the run-time. The user sets a nominal size for the cache. The cache will grow to this size and a little more, but from time to time discard the "little more" on the basis of a score that depends on recency of use.
-
-
Constructor Summary
Constructors Constructor Description LimitedCache(int capacity)
Construct a cache that will hold (at least) the specified number of entries.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(K key, V value)
Add a value corresponding to a given key.V
get(K key)
Get a value corresponding to the key, if it was previously cached.java.lang.String
toString()
-
-
-
Method Detail
-
get
public V get(K key)
Get a value corresponding to the key, if it was previously cached.- Parameters:
key
- against which cached- Returns:
- the cached value or
null
if not present
-
add
public void add(K key, V value)
Add a value corresponding to a given key.- Parameters:
key
- against which to cache the valuevalue
- to store
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-