Package uk.num.numlib.internal.util
Class SimpleCache<K,V>
- java.lang.Object
-
- uk.num.numlib.internal.util.SimpleCache<K,V>
-
- Type Parameters:
K- The class that the keys will be instances of.V- The class that the values will be instances of.
public final class SimpleCache<K,V> extends java.lang.ObjectA very basic cache with a timeout mechanism.
-
-
Constructor Summary
Constructors Constructor Description SimpleCache()Default Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vget(K key)Get an item from the cache.voidput(K key, V value)Add an item to the cache.voidsetTimeToLive(int millis)Override the default cache timeout.
-
-
-
Method Detail
-
setTimeToLive
public void setTimeToLive(int millis)
Override the default cache timeout. Can be set at any time but only affects items cached after the value is set.- Parameters:
millis- The number of milliseconds until the cached item should be considered stale.
-
put
public void put(K key, V value)
Add an item to the cache.- Parameters:
key- The key of class Kvalue- The value of class V
-
-