public abstract class AbstractMemoryCache<K,V> extends Object implements IMemoryCache<K,V>
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.
|
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
|
Set<K> |
getKeySet()
Get an Array 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.
|
void |
initialize(CompositeCache<K,V> hub)
For post reflection creation initialization
|
protected abstract void |
lockedGetElement(MemoryElementDescriptor<K,V> me)
Update control structures after get
(guarded by the lock)
|
protected abstract void |
lockedRemoveAll()
Removes all cached items from the cache control structures.
|
protected abstract void |
lockedRemoveElement(MemoryElementDescriptor<K,V> me)
Remove element from control structure
(guarded by the lock)
|
boolean |
remove(K key)
Removes an item from the cache.
|
void |
removeAll()
Removes all cached items from the cache.
|
protected boolean |
removeByGroup(K key)
Remove all keys of the same group hierarchy.
|
protected boolean |
removeByHierarchy(K key)
Remove all keys of the same name hierarchy.
|
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 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 void removeAll() throws IOException
removeAll
in interface IMemoryCache<K,V>
IOException
protected abstract void lockedRemoveAll()
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 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>
protected boolean removeByGroup(K key)
key
- the keyprotected boolean removeByHierarchy(K key)
key
- the keyprotected abstract void lockedRemoveElement(MemoryElementDescriptor<K,V> me)
me
- the memory element descriptorpublic boolean remove(K key) throws IOException
remove
in interface IMemoryCache<K,V>
key
- IOException
public Set<K> getKeySet()
getKeySet
in interface IMemoryCache<K,V>
public ICacheElement<K,V> get(K key) throws IOException
get
in interface IMemoryCache<K,V>
key
- Identifies item to findIOException
protected abstract void lockedGetElement(MemoryElementDescriptor<K,V> me)
me
- the memory element descriptorCopyright © 2002–2022 The Apache Software Foundation. All rights reserved.