K
- the key type. This must have both Object.equals(Object)
and Object.hashCode()
correctly implemented.V
- the value type. It is generally recommended to use an immutable
type here, but this is not required.X
- the type of exception thrown. If no exception will be throws, use
NeverThrownRuntimeException
.public class BasicCache<K,V,X extends java.lang.Exception> extends java.lang.Object implements ICache<K,V,X>
Constructor and Description |
---|
BasicCache(java.lang.String name,
IParameterizedFactory<V,K,X> factory,
ICacheBackend<K,V> backend)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear(boolean allThreads)
Clears the cache, i.e.
|
int |
getHits()
Returns the number of cache hits so far.
|
long |
getMissCostMillis()
Returns an estimation of the overhead caused by cache misses in
milliseconds.
|
int |
getMisses()
Returns the number of cache misses so far.
|
java.lang.String |
getName()
Returns the name (used for reporting).
|
V |
obtain(K key)
Obtain the value for a key.
|
public BasicCache(java.lang.String name, IParameterizedFactory<V,K,X> factory, ICacheBackend<K,V> backend)
public java.lang.String getName()
public void clear(boolean allThreads)
public V obtain(K key) throws X extends java.lang.Exception
public int getHits()
public int getMisses()
public long getMissCostMillis()
getMissCostMillis
in interface ICache<K,V,X extends java.lang.Exception>