public abstract class AbstractMemoryCache<K,V> extends Object implements IMemoryCache<K,V>
This keeps a static reference to a memory shrinker clock daemon. If this region is configured to use the shrinker, the clock daemon will be setup to run the shrinker on this region.
Modifier and Type | Field and Description |
---|---|
protected int |
chunkSize
How many to spool at a time.
|
protected AtomicLong |
hitCnt
number of hits
|
protected Lock |
lock |
protected Map<K,MemoryElementDescriptor<K,V>> |
map
Map where items are stored by key.
|
protected AtomicLong |
missCnt
number of misses
|
protected AtomicLong |
putCnt
number of puts
|
Constructor and Description |
---|
AbstractMemoryCache() |
Modifier and Type | Method and Description |
---|---|
abstract Map<K,MemoryElementDescriptor<K,V>> |
createMap()
Children must implement this method.
|
void |
dispose()
Prepares for shutdown.
|
void |
dumpMap()
Dump the cache map for debugging.
|
abstract ICacheElement<K,V> |
get(K key)
Get an item from the cache
|
ICompositeCacheAttributes |
getCacheAttributes()
Returns the CacheAttributes.
|
String |
getCacheName()
Returns the cache (aka "region") name.
|
CompositeCache<K,V> |
getCompositeCache()
Gets the cache hub / region that the MemoryCache is used by
|
abstract Set<K> |
getKeySet()
Get a set of the keys for all elements in the memory cache
|
Map<K,ICacheElement<K,V>> |
getMultiple(Set<K> keys)
Gets multiple items from the cache based on the given set of keys.
|
ICacheElement<K,V> |
getQuiet(K key)
Get an item from the cache without affecting its last access time or position.
|
int |
getSize()
Returns the current cache size.
|
IStats |
getStatistics()
Returns the historical and statistical data for a region's memory cache.
|
CacheStatus |
getStatus()
Returns the cache status.
|
void |
initialize(CompositeCache<K,V> hub)
For post reflection creation initialization
|
abstract boolean |
remove(K key)
Removes an item from the cache
|
void |
removeAll()
Removes all cached items from the cache.
|
void |
setCacheAttributes(ICompositeCacheAttributes cattr)
Sets the CacheAttributes.
|
abstract void |
update(ICacheElement<K,V> ce)
Puts an item to the cache.
|
void |
waterfal(ICacheElement<K,V> ce)
Puts an item to the cache.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
freeElements
protected int chunkSize
protected Map<K,MemoryElementDescriptor<K,V>> map
protected AtomicLong hitCnt
protected AtomicLong missCnt
protected AtomicLong putCnt
public AbstractMemoryCache()
public void initialize(CompositeCache<K,V> hub)
initialize
in interface IMemoryCache<K,V>
hub
- public abstract Map<K,MemoryElementDescriptor<K,V>> createMap()
public abstract boolean remove(K key) throws IOException
remove
in interface IMemoryCache<K,V>
key
- Identifies item to be removedIOException
- Description of the Exceptionpublic abstract ICacheElement<K,V> get(K key) throws IOException
get
in interface IMemoryCache<K,V>
key
- Description of the ParameterIOException
- Description of the Exceptionpublic Map<K,ICacheElement<K,V>> getMultiple(Set<K> keys) throws IOException
getMultiple
in interface IMemoryCache<K,V>
keys
- IOException
public ICacheElement<K,V> getQuiet(K key) throws IOException
getQuiet
in interface IMemoryCache<K,V>
key
- Identifies item to findIOException
public abstract void update(ICacheElement<K,V> ce) throws IOException
update
in interface IMemoryCache<K,V>
ce
- Description of the ParameterIOException
- Description of the Exceptionpublic abstract Set<K> getKeySet()
getKeySet
in interface IMemoryCache<K,V>
public void removeAll() throws IOException
removeAll
in interface IMemoryCache<K,V>
IOException
public void dispose() throws IOException
dispose
in interface IMemoryCache<K,V>
IOException
public IStats getStatistics()
IMemoryCache
getStatistics
in interface IMemoryCache<K,V>
public int getSize()
getSize
in interface IMemoryCache<K,V>
public CacheStatus getStatus()
public String getCacheName()
public void waterfal(ICacheElement<K,V> ce)
waterfal
in interface IMemoryCache<K,V>
ce
- the itempublic void dumpMap()
public ICompositeCacheAttributes getCacheAttributes()
getCacheAttributes
in interface IMemoryCache<K,V>
public void setCacheAttributes(ICompositeCacheAttributes cattr)
setCacheAttributes
in interface IMemoryCache<K,V>
cattr
- The new CacheAttributes valuepublic CompositeCache<K,V> getCompositeCache()
getCompositeCache
in interface IMemoryCache<K,V>
Copyright © 2002–2018 The Apache Software Foundation. All rights reserved.