ehcache

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 (CHM like), is to evict when required.

Author:
Alex Snaps
See Also:
ConcurrentHashMap

Nested Class Summary
static interface HeapCacheBackEnd.EvictionCallback<K,V>
          An eviction callback
 
Method Summary
 void clear(boolean notify)
          Basically CHM.clear()
 Set<Map.Entry<K,V>> entrySet()
          Deprecated. 
 V get(K key)
          Access a key, basically CHM.get()
 Policy getPolicy()
          Deprecated. 
 boolean hasSpace()
          Return true if this tier has enough space for more entries.
 V putIfAbsent(K key, V value)
          Basically ConcurrentMap.putIfAbsent(Object, Object) CHM.putIfAbsent(Object, Object)}, but will evict if required (on successful put)
 void recalculateSize(K key)
          Deprecated. 
 void registerEvictionCallback(HeapCacheBackEnd.EvictionCallback<K,V> callback)
          Let's you register a single callback for evictions
 V remove(K key)
          Basically CHM.remove(Object)
 boolean remove(K key, V value)
          Basically ConcurrentMap.remove(Object, Object) CHM.remove(Object, Object)}
 boolean replace(K key, V oldValue, V newValue)
          Basically CHM.remove(Object, Object, Object)
 void setPolicy(Policy policy)
          Deprecated. 
 int size()
          Deprecated. 
 

Method Detail

hasSpace

boolean hasSpace()
Return true if this tier has enough space for more entries.

Returns:
true if there is space for more entries.

get

V get(K key)
Access a key, basically CHM.get()

Parameters:
key - the key whose associated value is to be returned
Returns:
the value to which the specified key is mapped, or null if this map contains no mapping for the key

putIfAbsent

V putIfAbsent(K key,
              V value)
Basically ConcurrentMap.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 associated
value - 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)
Basically ConcurrentMap.remove(Object, Object) CHM.remove(Object, Object)}

Parameters:
key - key with which the specified value is associated
value - 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)
Basically CHM.remove(Object, Object, Object)

Parameters:
key - key with which the specified value is associated
oldValue - value expected to be associated with the specified key
newValue - value to be associated with the specified key
Returns:
true if the value was replaced

remove

V remove(K key)
Basically CHM.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)
Basically CHM.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
Set<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

ehcache

Copyright 2001-2014, Terracotta, Inc.