K - The type of keys maintainedV - The type of values maintainedpublic class ExpiringCache<K,V>
extends java.lang.Object
| Constructor and Description |
|---|
ExpiringCache(long expireAfterMs,
java.util.function.Function<K,V> getter)
Create a new ExpiringCache that will expire entries after a given number of milliseconds
computing the values as needed using the given getter.
|
ExpiringCache(long expireAfterMs,
java.util.function.Function<K,V> getter,
long expirationFreqMs,
Clock clock)
For unit tests.
|
| Modifier and Type | Method and Description |
|---|---|
V |
get(K key)
Get the (possibly cached) value for a given key.
|
int |
size()
Return the number of entries in the cache.
|
java.lang.String |
toString() |
java.util.List<V> |
values()
Get the list of all values that are members of this cache.
|
public ExpiringCache(long expireAfterMs,
java.util.function.Function<K,V> getter)
expireAfterMs - Number of milliseconds after which entries will be evictedgetter - Function that will be used to compute the valuespublic ExpiringCache(long expireAfterMs,
java.util.function.Function<K,V> getter,
long expirationFreqMs,
Clock clock)
expireAfterMs - Number of milliseconds after which entries will be evictedgetter - Function that will be used to compute the valuesexpirationFreqMs - Frequency at which to schedule the job that evicts entries
from the cache.public java.util.List<V> values()
public int size()
public java.lang.String toString()
toString in class java.lang.Object