K
- The key typeV
- the value typepublic class OnHeapCachingTier<K,V> extends Object implements CachingTier<K,V>
CachingTier.Listener<K,V>
Constructor and Description |
---|
OnHeapCachingTier(HeapCacheBackEnd<K,Object> backEnd)
A Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(CachingTier.Listener<K,V> listener)
Adds a
CachingTier.Listener to the cache |
void |
clear()
Clears the cache...
|
void |
clearAndNotify()
Clears the cache notifying listeners
|
boolean |
contains(K key)
This should go away once the stats are in
As the method is only there to know what tier the key is going to be fetched from
|
static OnHeapCachingTier<Object,Element> |
createOnHeapCache(Ehcache cache,
Pool onHeapPool)
Factory method
|
V |
get(K key,
Callable<V> source,
boolean updateStats)
Returns the value associated with the key, or populates the mapping using the Callable instance
|
Policy |
getEvictionPolicy()
queries the potential eviction policy for the heap caching tier
|
int |
getInMemorySize()
Can we avoid having this somehow ?
|
long |
getInMemorySizeInBytes()
CacheTier could keep hold of the PoolAccessors for each tier...
|
int |
getOffHeapSize()
Can we avoid having this somehow ?
|
long |
getOffHeapSizeInBytes()
CacheTier could keep hold of the PoolAccessors for each tier...
|
long |
getOnDiskSizeInBytes()
CacheTier could keep hold of the PoolAccessors for each tier...
|
boolean |
loadOnPut()
Returns
true if values should be loaded to this cache on put. |
void |
recalculateSize(K key)
This is evil! Don't call this!
|
V |
remove(K key)
Removes the mapping associated to the key passed in
|
void |
setEvictionPolicy(Policy policy)
sets the eviction policy on the heap caching tier
|
public OnHeapCachingTier(HeapCacheBackEnd<K,Object> backEnd)
backEnd
- the HeapCacheBackEnd that will back this CachingTierpublic static OnHeapCachingTier<Object,Element> createOnHeapCache(Ehcache cache, Pool onHeapPool)
cache
- the cache we're planning to backonHeapPool
- the pool, if any, to usepublic boolean loadOnPut()
CachingTier
true
if values should be loaded to this cache on put.
This may be a dynamic decision, based for example on the occupancy of the cache.
loadOnPut
in interface CachingTier<K,V>
true
if values should be loaded on putpublic V get(K key, Callable<V> source, boolean updateStats)
CachingTier
get
in interface CachingTier<K,V>
key
- the key to look upsource
- the source to use, in the case of no mapping presentupdateStats
- true to update the stats, false otherwisepublic V remove(K key)
CachingTier
remove
in interface CachingTier<K,V>
key
- the key to the mapping to removepublic void clear()
CachingTier
clear
in interface CachingTier<K,V>
public void clearAndNotify()
CachingTier
clearAndNotify
in interface CachingTier<K,V>
public void addListener(CachingTier.Listener<K,V> listener)
CachingTier
CachingTier.Listener
to the cacheaddListener
in interface CachingTier<K,V>
listener
- the listener to addpublic int getInMemorySize()
CachingTier
getInMemorySize
in interface CachingTier<K,V>
public int getOffHeapSize()
CachingTier
getOffHeapSize
in interface CachingTier<K,V>
public boolean contains(K key)
CachingTier
contains
in interface CachingTier<K,V>
public long getInMemorySizeInBytes()
CachingTier
getInMemorySizeInBytes
in interface CachingTier<K,V>
public long getOffHeapSizeInBytes()
CachingTier
getOffHeapSizeInBytes
in interface CachingTier<K,V>
public long getOnDiskSizeInBytes()
CachingTier
getOnDiskSizeInBytes
in interface CachingTier<K,V>
public void recalculateSize(K key)
CachingTier
recalculateSize
in interface CachingTier<K,V>
key
- the key to perform the recalculation forpublic Policy getEvictionPolicy()
CachingTier
getEvictionPolicy
in interface CachingTier<K,V>
public void setEvictionPolicy(Policy policy)
CachingTier
setEvictionPolicy
in interface CachingTier<K,V>
policy
- the policy to useCopyright © 2003–2016 Terracotta, Inc.. All rights reserved.