Top Description Inners Methods
net.sf.ehcache.store.cachingtier

public Interface HeapCacheBackEnd<K, V>

Known Direct Implementers
net.sf.ehcache.store.cachingtier.PooledBasedBackEnd, net.sf.ehcache.store.cachingtier.CountBasedBackEnd
Imports
net.sf.ehcache.store.Policy, java.util.Map, .Set

A backend to a OnHeapCachingTier It's responsibility, beyond being the actual storage (CHM like), is to evict when required.
Author
Alex Snaps
See Also
java.util.concurrent.ConcurrentHashMap

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
HeapCacheBackEnd.EvictionCallback<
the key type
K
,
the value type
V
>

An eviction callback

Method Summary

Modifier and TypeMethod and Description
public void
clear(final boolean
whether to notify listeners or not
notify
)

Basically CHM.clear()

public Set<Map.Entry<K, V>>

Returns:

the Set of entries
entrySet
()

Deprecated
This should go away with the new stats I believe
public V

Returns:

the value to which the specified key is mapped, or null if this map contains no mapping for the key
get
(K
the key whose associated value is to be returned
key
)

Access a key, basically CHM.get()

public Policy

Returns:

the policy
getPolicy
()

Deprecated
queries the potential eviction policy for the heap caching tier
public boolean

Returns:

true if there is space for more entries.
hasSpace
()

Return true if this tier has enough space for more entries.

public V

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.)
putIfAbsent
(K
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Basically java.util.concurrent.ConcurrentMap#putIfAbsent(Object, Object) CHM.putIfAbsent(Object, Object)}, but will evict if required (on successful put)

public void
recalculateSize(K key)

Deprecated
This is evil!
public void
registerEvictionCallback(HeapCacheBackEnd.EvictionCallback<K, V>
the thing to call back on
callback
)

Let's you register a single callback for evictions

public boolean

Returns:

true if the value was removed
remove
(K
key with which the specified value is associated
key
,
V
value expected to be associated with the specified key
value
)

Basically java.util.concurrent.ConcurrentMap#remove(Object, Object) CHM.remove(Object, Object)}

public V

Returns:

the previous value associated with key, or null if there was no mapping for key.
remove
(K
key whose mapping is to be removed from the map
key
)

Basically CHM.remove(Object)

public boolean

Returns:

true if the value was replaced
replace
(K
key with which the specified value is associated
key
,
V
value expected to be associated with the specified key
oldValue
,
V
value to be associated with the specified key
newValue
)

Basically CHM.remove(Object, Object, Object)

public void
setPolicy(Policy
the policy to use
policy
)

Deprecated
sets the eviction policy on the heap caching tier
public int

Returns:

the amount of mappings installed
size
()

Deprecated
This should go away with the new stats I believe

Method Detail

clearback to summary
public void clear(final boolean notify)

Basically CHM.clear()

Parameters
notify:boolean

whether to notify listeners or not

entrySetback to summary
public Set<Map.Entry<K, V>> entrySet()

Deprecated

This should go away with the new stats I believe

Returns:Set<Map.Entry<K, V>>

the Set of entries

Annotations
@Deprecated
getback to summary
public V get(K key)

Access a key, basically CHM.get()

Parameters
key:K

the key whose associated value is to be returned

Returns:V

the value to which the specified key is mapped, or null if this map contains no mapping for the key

getPolicyback to summary
public Policy getPolicy()

Deprecated

queries the potential eviction policy for the heap caching tier

Returns:Policy

the policy

Annotations
@Deprecated
hasSpaceback to summary
public boolean hasSpace()

Return true if this tier has enough space for more entries.

Returns:boolean

true if there is space for more entries.

putIfAbsentback to summary
public V putIfAbsent(K key, V value)

Basically java.util.concurrent.ConcurrentMap#putIfAbsent(Object, Object) CHM.putIfAbsent(Object, Object)}, but will evict if required (on successful put)

Parameters
key:K

key with which the specified value is to be associated

value:V

value to be associated with the specified key

Returns:V

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.)

recalculateSizeback to summary
public void recalculateSize(K key)

Deprecated

This is evil! Don't call this!

Annotations
@Deprecated
registerEvictionCallbackback to summary
public void registerEvictionCallback(HeapCacheBackEnd.EvictionCallback<K, V> callback)

Let's you register a single callback for evictions

Parameters
callback:HeapCacheBackEnd.EvictionCallback<K, V>

the thing to call back on

removeback to summary
public boolean remove(K key, V value)

Basically java.util.concurrent.ConcurrentMap#remove(Object, Object) CHM.remove(Object, Object)}

Parameters
key:K

key with which the specified value is associated

value:V

value expected to be associated with the specified key

Returns:boolean

true if the value was removed

removeback to summary
public V remove(K key)

Basically CHM.remove(Object)

Parameters
key:K

key whose mapping is to be removed from the map

Returns:V

the previous value associated with key, or null if there was no mapping for key.

replaceback to summary
public boolean replace(K key, V oldValue, V newValue)

Basically CHM.remove(Object, Object, Object)

Parameters
key:K

key with which the specified value is associated

oldValue:V

value expected to be associated with the specified key

newValue:V

value to be associated with the specified key

Returns:boolean

true if the value was replaced

setPolicyback to summary
public void setPolicy(Policy policy)

Deprecated

sets the eviction policy on the heap caching tier

Parameters
policy:Policy

the policy to use

Annotations
@Deprecated
sizeback to summary
public int size()

Deprecated

This should go away with the new stats I believe

Returns:int

the amount of mappings installed

Annotations
@Deprecated
net.sf.ehcache.store.cachingtier back to summary

public Interface HeapCacheBackEnd.EvictionCallback<K, V>

Type Parameters
<K>
the key type
<V>
the value type

An eviction callback

Method Summary

Modifier and TypeMethod and Description
public void
evicted(K
the evicted key
key
,
V
the evicted value
value
)

Called upon eviction (the mapping is gone already)

Method Detail

evictedback to summary
public void evicted(K key, V value)

Called upon eviction (the mapping is gone already)

Parameters
key:K

the evicted key

value:V

the evicted value