public class CacheMap<K,V> extends LinkedHashMap<K,V>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
CacheMap(int numEntries) |
CacheMap(int numEntries,
float loadFactor) |
CacheMap(int numEntries,
float loadFactor,
boolean accessOrder) |
CacheMap(int numEntries,
float loadFactor,
boolean accessOrder,
String backingFile)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static <K,V> CacheMap<K,V> |
create(int numEntries,
float loadFactor,
boolean accessOrder,
String file,
boolean useFileParams)
Creates a new file-backed CacheMap or loads it in from the specified file
if it already exists.
|
static <K,V> CacheMap<K,V> |
create(int numEntries,
float loadFactor,
String file,
boolean useFileParams) |
static <K,V> CacheMap<K,V> |
create(int numEntries,
String file,
boolean useFileParams) |
static <K,V> CacheMap<K,V> |
create(String file,
boolean useFileParams) |
V |
get(Object key) |
void |
printStats(PrintStream out)
Print out cache stats to the specified stream.
|
V |
put(K key,
V value)
Add the entry to the map, and dump the map to a file if it's been a while
since we last did.
|
protected boolean |
removeEldestEntry(Map.Entry<K,V> eldest) |
void |
write()
Dump out the contents of the cache to the backing file.
|
clear, containsValue, entrySet, forEach, getOrDefault, keySet, replaceAll, valuesclone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putAll, putIfAbsent, remove, remove, replace, replace, sizeequals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, remove, replace, replace, sizepublic CacheMap(int numEntries,
float loadFactor,
boolean accessOrder,
String backingFile)
numEntries - is the number of entries you want to store in the
CacheMap. This is not the same as the number of
buckets - that is effected by this and the target
loadFactor.accessOrder - is the same as in LinkedHashMap.backingFile - is the name of the file to dump this to, if desired.LinkedHashMappublic CacheMap(int numEntries,
float loadFactor,
boolean accessOrder)
public CacheMap(int numEntries,
float loadFactor)
public CacheMap(int numEntries)
public static <K,V> CacheMap<K,V> create(int numEntries, float loadFactor, boolean accessOrder, String file, boolean useFileParams)
public static <K,V> CacheMap<K,V> create(int numEntries, float loadFactor, String file, boolean useFileParams)
public void write()
protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
removeEldestEntry in class LinkedHashMap<K,V>LinkedHashMap.removeEldestEntry(java.util.Map.Entry<K, V>)public V get(Object key)
get in interface Map<K,V>get in class LinkedHashMap<K,V>HashMap.get(java.lang.Object)public V put(K key, V value)
public void printStats(PrintStream out)