public class Cache<K,V> extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Cache.Loader<L,W> |
Constructor and Description |
---|
Cache(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.
|
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(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() |
String |
toString() |
public Cache(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 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.Loader<K,V> handler)
Copyright © 2024. All rights reserved.