K - the key typeV - the value typepublic class CountBasedBackEnd<K,V> extends ConcurrentHashMap<K,V> implements HeapCacheBackEnd<K,V>
ConcurrentHashMap.EntrySetView<K,V>, ConcurrentHashMap.KeySetView<K,V>, ConcurrentHashMap.Node, ConcurrentHashMap.RemovalCallback, ConcurrentHashMap.Spliterator<T>, ConcurrentHashMap.TreeNode, ConcurrentHashMap.ValuesView<K,V>HeapCacheBackEnd.EvictionCallback<K,V>FAKE_NODE, FAKE_TREE_NODE| Constructor and Description |
|---|
CountBasedBackEnd(long maxEntriesLocalHeap)
Constructs a cap'ed backend
|
CountBasedBackEnd(long maxEntriesLocalHeap,
Policy policy)
Constructs a cap'ed backend
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear(boolean notify)
Basically
CHM.clear() |
long |
getMaxEntriesLocalHeap()
Reads the current capacity limit
|
Policy |
getPolicy()
queries the potential eviction policy for the heap caching tier
|
boolean |
hasSpace()
Return
true if this tier has enough space for more entries. |
V |
putIfAbsent(K key,
V value) |
void |
recalculateSize(K key)
This is evil! Don't call this!
|
void |
registerEvictionCallback(HeapCacheBackEnd.EvictionCallback<K,V> evictionCallback)
Let's you register a single callback for evictions
|
V |
remove(Object key)
Removes the key (and its corresponding value) from this map.
|
void |
setMaxEntriesLocalHeap(long maxEntriesLocalHeap)
Sets the capacity limit
|
void |
setPolicy(Policy policy)
Dynamic property to switch the policy out
|
clear, contains, containsKey, containsValue, elements, entrySet, entrySpliterator, equals, get, getRandomValues, getValueOrDefault, hashCode, internalPutIfAbsent, isEmpty, keys, keySet, keySet, keySpliterator, mappingCount, newKeySet, newKeySet, put, putAll, remove, remove, removeAndNotify, removeAndNotify, replace, replace, setPoolAccessor, size, toString, values, valueSpliteratorclone, finalize, getClass, notify, notifyAll, wait, wait, waitentrySet, get, remove, replace, sizecompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAllpublic CountBasedBackEnd(long maxEntriesLocalHeap)
maxEntriesLocalHeap - amount of mappings this should hold before it starts evictingpublic CountBasedBackEnd(long maxEntriesLocalHeap,
Policy policy)
maxEntriesLocalHeap - amount of mappings this should hold before it starts evictingpolicy - the policy it'll use to decide what to evictpublic void setPolicy(Policy policy)
setPolicy in interface HeapCacheBackEnd<K,V>policy - the new eviction Policy to usepublic V putIfAbsent(K key, V value)
putIfAbsent in interface ConcurrentMap<K,V>putIfAbsent in interface Map<K,V>putIfAbsent in interface HeapCacheBackEnd<K,V>putIfAbsent in class ConcurrentHashMap<K,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keynull if there was no mapping for the keypublic void registerEvictionCallback(HeapCacheBackEnd.EvictionCallback<K,V> evictionCallback)
registerEvictionCallback in interface HeapCacheBackEnd<K,V>evictionCallback - the thing to call back onpublic void recalculateSize(K key)
HeapCacheBackEndrecalculateSize in interface HeapCacheBackEnd<K,V>recalculateSize in class ConcurrentHashMap<K,V>public V remove(Object key)
ConcurrentHashMappublic Policy getPolicy()
HeapCacheBackEndgetPolicy in interface HeapCacheBackEnd<K,V>public void clear(boolean notify)
HeapCacheBackEndCHM.clear()clear in interface HeapCacheBackEnd<K,V>notify - whether to notify listeners or notpublic boolean hasSpace()
HeapCacheBackEndtrue if this tier has enough space for more entries.hasSpace in interface HeapCacheBackEnd<K,V>true if there is space for more entries.public void setMaxEntriesLocalHeap(long maxEntriesLocalHeap)
maxEntriesLocalHeap - the new limitpublic long getMaxEntriesLocalHeap()
Copyright 2001-2021, Terracotta, Inc.