public abstract class AbstractMapBackedCache<K,V,M extends MetaData> extends AbstractCache<K,V> implements Cache<K,V>
UNLIMITED_IDLE_TIME| Constructor and Description |
|---|
AbstractMapBackedCache(String name,
long defaultTimeToLive,
ExpungeStrategy expungeStrategy)
Construct a new AbstractCache.
|
AbstractMapBackedCache(String name,
long defaultTimeToLive,
long defaultMaxIdleTime,
ExpungeStrategy expungeStrategy)
Construct a new AbstractCache.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Cleanup the cache.
|
void |
delete(K key)
Manually remove an entry from the cache.
|
void |
delete(K key,
M metaData) |
protected abstract void |
doDelete(K key,
M metaData)
Performs deletion of the data belonging to the metadata.
|
protected abstract V |
doGet(K key,
M metaData)
Performs retrieval of the data belonging to the metadata.
|
protected abstract V |
doPut(K key,
V data)
Performs storage of the given data and adds new metadata to the map.
|
protected void |
expunge(Collection<Map.Entry<K,M>> expungeEntriesMetaData)
Performs the actual expunging of entries with the given metadata.
|
V |
get(K key)
Retrieve an entry from the cache if it is available.
|
List<M> |
getEntriesMetaData()
Returns a copy of the List of all metadata entries.
|
protected Map<K,M> |
getEntriesMetaDataMap() |
ExpungeStrategy |
getExpungeStrategy() |
MetaData |
getMetaData(K key)
Retrieve the
MetaData of a cached entry if it is available. |
SimpleCacheStatistics |
getStatistics()
Get statistics of the cache like hitrate, or size.
|
V |
put(K key,
V data)
Store an entry in the cache with the default time to live.
|
protected void |
setEntriesMetaDataMap(Map<K,M> map) |
void |
setExpungeStrategy(ExpungeStrategy expungeStrategy) |
getCleanUpLogger, getDefaultMaxIdleTime, getDefaultTtl, getLogger, getName, setDefaultMaxIdleTime, setDefaultTtlclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDefaultMaxIdleTime, getDefaultTtl, getNamepublic AbstractMapBackedCache(String name, long defaultTimeToLive, ExpungeStrategy expungeStrategy)
name - The name of the cache.defaultTimeToLive - The default time to live for Cache entries.expungeStrategy - The ExpungeStrategy to use.public AbstractMapBackedCache(String name, long defaultTimeToLive, long defaultMaxIdleTime, ExpungeStrategy expungeStrategy)
name - The name of the cache.defaultTimeToLive - The default time to live for Cache entries.defaultMaxIdleTime - The default max idle time for cache entries.expungeStrategy - The ExpungeStrategy to use.public final V put(K key, V data) throws CacheException
Cacheput in interface Cache<K,V>key - A unique identifier.data - The data to store. Make sure that you don't alter the data after it has been put
to cache as (depending on the implementation) this might lead to altering the
entry in the cache. Use the returned data instead.CacheException - Thrown on any errors encountered, supposed to include the stacktrace (if any).public final void delete(K key) throws CacheException
Cachedelete in interface Cache<K,V>key - The key under which the entry was stored.CacheException - Thrown on any errors encountered, supposed to include the stacktrace (if any).public final void cleanUp()
throws CacheException
CachecleanUp in interface Cache<K,V>CacheException - Thrown on any errors encountered, supposed to include the stacktrace (if any).public MetaData getMetaData(K key) throws CacheException
CacheMetaData of a cached entry if it is available.getMetaData in interface Cache<K,V>key - The key under which the entry was stored.MetaData of the entry if found, null otherwise.CacheException - Thrown on any errors encountered, supposed to include the stacktrace (if any).public final V get(K key) throws CacheException
Cacheget in interface Cache<K,V>key - The unique key under which the entry was stored.CacheException - Thrown on any errors encountered, supposed to include the stacktrace (if any).public SimpleCacheStatistics getStatistics()
CachegetStatistics in interface Cache<K,V>public ExpungeStrategy getExpungeStrategy()
public void setExpungeStrategy(ExpungeStrategy expungeStrategy)
protected void expunge(Collection<Map.Entry<K,M>> expungeEntriesMetaData) throws CacheException
expungeEntriesMetaData - A List of the MetaData of the entries to expunge.CacheException - Thrown on any errors encountered.public void delete(K key, M metaData) throws CacheException
CacheExceptionpublic List<M> getEntriesMetaData()
protected abstract void doDelete(K key, M metaData) throws CacheException
CacheExceptionprotected abstract V doGet(K key, M metaData) throws CacheException
CacheExceptionprotected abstract V doPut(K key, V data) throws CacheException
CacheExceptionCopyright © 2013 dontdrinkandroot. All Rights Reserved.