public class Cache<K,V> extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Cache.MissHandler<L,W> |
| Constructor and Description |
|---|
Cache(String name,
int size,
Cache.MissHandler<K,V> missHandler)
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.
|
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(String name,
int size,
Cache.MissHandler<K,V> handler) |
V |
put(K key,
V value)
This will put a specific entry in the cache
|
void |
stopLogging() |
String |
toString() |
public Cache(String name, int size, Cache.MissHandler<K,V> missHandler)
name - the name of the cache for loggingsize - the maximum size of the logmissHandler - how to handle misses, 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 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 static <K,V> Cache<K,V> make(String name, int size, Cache.MissHandler<K,V> handler)
Copyright © 2016. All rights reserved.