public class Cache<K,V>
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Cache.Loader<L,W> |
| Constructor and Description |
|---|
Cache(java.lang.String name,
int size,
Cache.Loader<K,V> loader)
This will create a new cache
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
V |
evict(K key)
This will evict a specific key from the cache.
|
V |
get(K key)
This will get a specific entry, it will call the missHandler if it is not found.
|
java.lang.Iterable<V> |
getCachedValues() |
int |
getConfiguredSize() |
double |
getHitRate() |
int |
getHits() |
int |
getMisses() |
int |
getRequests() |
int |
getUtilizedSize() |
Cache<K,V> |
logEveryNSeconds(int seconds,
ILogger logger)
Sets up a recurring task every n seconds to report on the status of this cache.
|
static <K,V> Cache<K,V> |
make(java.lang.String name,
int size,
Cache.Loader<K,V> handler) |
V |
put(K key,
V value)
This will put a specific entry in the cache
|
void |
stopLogging() |
java.lang.String |
toString() |
public Cache(java.lang.String name,
int size,
Cache.Loader<K,V> loader)
name - the name of the cache for loggingsize - the maximum size of the logloader - loads values into the cache, this is required not to be nullpublic V evict(K key)
key - the key to evictpublic V put(K key, V value)
key - this is the keyvalue - this is the valuepublic V get(K key)
key - the object to findpublic java.lang.Iterable<V> getCachedValues()
public int getConfiguredSize()
public int getUtilizedSize()
public int getRequests()
public int getMisses()
public int getHits()
public double getHitRate()
public Cache<K,V> logEveryNSeconds(int seconds, ILogger logger)
seconds - how often to log the entrylogger - the logger to usepublic void stopLogging()
public void clear()
public java.lang.String toString()
toString in class java.lang.Objectpublic static <K,V> Cache<K,V> make(java.lang.String name, int size, Cache.Loader<K,V> handler)
Copyright © 2022. All rights reserved.