Package net.sf.ehcache.store.cachingtier
Interface HeapCacheBackEnd<K,V>
-
- Type Parameters:
K-V-
- All Known Implementing Classes:
CountBasedBackEnd,PooledBasedBackEnd
public interface HeapCacheBackEnd<K,V>A backend to a OnHeapCachingTier It's responsibility, beyond being the actual storage (CHMlike), is to evict when required.- Author:
- Alex Snaps
- See Also:
ConcurrentHashMap
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceHeapCacheBackEnd.EvictionCallback<K,V>An eviction callback
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidclear(boolean notify)BasicallyCHM.clear()java.util.Set<java.util.Map.Entry<K,V>>entrySet()Deprecated.Vget(K key)Access a key, basicallyCHM.get()PolicygetPolicy()Deprecated.booleanhasSpace()Returntrueif this tier has enough space for more entries.VputIfAbsent(K key, V value)BasicallyConcurrentMap.putIfAbsent(Object, Object)CHM.putIfAbsent(Object, Object)}, but will evict if required (on successful put)voidrecalculateSize(K key)Deprecated.voidregisterEvictionCallback(HeapCacheBackEnd.EvictionCallback<K,V> callback)Let's you register a single callback for evictionsVremove(K key)BasicallyCHM.remove(Object)booleanremove(K key, V value)BasicallyConcurrentMap.remove(Object, Object)CHM.remove(Object, Object)}booleanreplace(K key, V oldValue, V newValue)BasicallyCHM.remove(Object, Object, Object)voidsetPolicy(Policy policy)Deprecated.intsize()Deprecated.
-
-
-
Method Detail
-
hasSpace
boolean hasSpace()
Returntrueif this tier has enough space for more entries.- Returns:
trueif there is space for more entries.
-
get
V get(K key)
Access a key, basicallyCHM.get()- Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
nullif this map contains no mapping for the key
-
putIfAbsent
V putIfAbsent(K key, V value)
BasicallyConcurrentMap.putIfAbsent(Object, Object)CHM.putIfAbsent(Object, Object)}, but will evict if required (on successful put)- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Returns:
- the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)
-
remove
boolean remove(K key, V value)
BasicallyConcurrentMap.remove(Object, Object)CHM.remove(Object, Object)}- Parameters:
key- key with which the specified value is associatedvalue- value expected to be associated with the specified key- Returns:
- true if the value was removed
-
replace
boolean replace(K key, V oldValue, V newValue)
BasicallyCHM.remove(Object, Object, Object)- Parameters:
key- key with which the specified value is associatedoldValue- value expected to be associated with the specified keynewValue- value to be associated with the specified key- Returns:
- true if the value was replaced
-
remove
V remove(K key)
BasicallyCHM.remove(Object)- Parameters:
key- key whose mapping is to be removed from the map- Returns:
- the previous value associated with key, or null if there was no mapping for key.
-
clear
void clear(boolean notify)
BasicallyCHM.clear()- Parameters:
notify- whether to notify listeners or not
-
size
@Deprecated int size()
Deprecated.This should go away with the new stats I believe- Returns:
- the amount of mappings installed
-
entrySet
@Deprecated java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Deprecated.This should go away with the new stats I believe- Returns:
- the Set of entries
-
registerEvictionCallback
void registerEvictionCallback(HeapCacheBackEnd.EvictionCallback<K,V> callback)
Let's you register a single callback for evictions- Parameters:
callback- the thing to call back on
-
recalculateSize
@Deprecated void recalculateSize(K key)
Deprecated.This is evil! Don't call this!- Parameters:
key-
-
getPolicy
@Deprecated Policy getPolicy()
Deprecated.queries the potential eviction policy for the heap caching tier- Returns:
- the policy
-
setPolicy
@Deprecated void setPolicy(Policy policy)
Deprecated.sets the eviction policy on the heap caching tier- Parameters:
policy- the policy to use
-
-