Package org.python.core.util
Class LimitedCache<K,V>
java.lang.Object
org.python.core.util.LimitedCache<K,V>
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
ConstructorsConstructorDescriptionLimitedCache(int capacity) Construct a cache that will hold (at least) the specified number of entries. -
Method Summary
-
Constructor Details
-
LimitedCache
public LimitedCache(int capacity) Construct a cache that will hold (at least) the specified number of entries. (It will sometimes contain a few more so we don't have to scan the cache with every addition.)- Parameters:
capacity- the number of entries required
-
-
Method Details
-
get
Get a value corresponding to the key, if it was previously cached.- Parameters:
key- against which cached- Returns:
- the cached value or
nullif not present
-
add
Add a value corresponding to a given key.- Parameters:
key- against which to cache the valuevalue- to store
-
toString
-