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, valueSpliterator
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
entrySet, get, remove, replace, size
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
public 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)
HeapCacheBackEnd
recalculateSize
in interface HeapCacheBackEnd<K,V>
recalculateSize
in class ConcurrentHashMap<K,V>
public V remove(Object key)
ConcurrentHashMap
public Policy getPolicy()
HeapCacheBackEnd
getPolicy
in interface HeapCacheBackEnd<K,V>
public void clear(boolean notify)
HeapCacheBackEnd
CHM.clear()
clear
in interface HeapCacheBackEnd<K,V>
notify
- whether to notify listeners or notpublic boolean hasSpace()
HeapCacheBackEnd
true
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 © 2003–2016 Terracotta, Inc.. All rights reserved.