public class CacheMap<K,V>
extends java.util.LinkedHashMap<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,
java.lang.String backingFile)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static <K,V> CacheMap<K,V> |
create(int numEntries,
float loadFactor,
boolean accessOrder,
java.lang.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,
java.lang.String file,
boolean useFileParams) |
static <K,V> CacheMap<K,V> |
create(int numEntries,
java.lang.String file,
boolean useFileParams) |
static <K,V> CacheMap<K,V> |
create(java.lang.String file,
boolean useFileParams) |
V |
get(java.lang.Object key) |
void |
printStats(java.io.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(java.util.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, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putAll, putIfAbsent, remove, remove, replace, replace, size
public CacheMap(int numEntries, float loadFactor, boolean accessOrder, java.lang.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.LinkedHashMap
public 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, java.lang.String file, boolean useFileParams)
public static <K,V> CacheMap<K,V> create(int numEntries, float loadFactor, java.lang.String file, boolean useFileParams)
public static <K,V> CacheMap<K,V> create(int numEntries, java.lang.String file, boolean useFileParams)
public static <K,V> CacheMap<K,V> create(java.lang.String file, boolean useFileParams)
public void write()
public V get(java.lang.Object key)
public V put(K key, V value)
public void printStats(java.io.PrintStream out)