|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.dontdrinkandroot.cache.impl.AbstractCache<K,V>
net.dontdrinkandroot.cache.impl.AbstractMapBackedCache<K,V,M>
public abstract class AbstractMapBackedCache<K,V,M extends MetaData>
| Field Summary |
|---|
| Fields inherited from interface net.dontdrinkandroot.cache.Cache |
|---|
UNLIMITED_IDLE_TIME |
| Constructor Summary | |
|---|---|
AbstractMapBackedCache(String name,
long defaultTimeToLive,
ExpungeStrategy expungeStrategy)
Construct a new AbstractCache. |
|
AbstractMapBackedCache(String name,
long defaultTimeToLive,
long defaultMaxIdleTime,
ExpungeStrategy expungeStrategy)
Construct a new AbstractCache. |
|
| Method Summary | ||
|---|---|---|
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
|
doGet(K key,
M metaData)
Performs retrieval of the data belonging to the metadata. |
|
protected abstract
|
doPut(K key,
T 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. |
|
|
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. |
|
|
getWithErrors(K key)
Retrieve an entry from the cache if it is available. |
|
|
put(K key,
T data)
Store an entry in the cache with the default time to live. |
|
|
putWithErrors(K key,
T data)
Store an entry in the cache with the default time to live. |
|
protected void |
setEntriesMetaDataMap(Map<K,M> map)
|
|
void |
setExpungeStrategy(ExpungeStrategy expungeStrategy)
|
|
| Methods inherited from class net.dontdrinkandroot.cache.impl.AbstractCache |
|---|
getCleanUpLogger, getDefaultMaxIdleTime, getDefaultTtl, getLogger, getName, setDefaultMaxIdleTime, setDefaultTtl |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.dontdrinkandroot.cache.Cache |
|---|
getDefaultMaxIdleTime, getDefaultTtl, getName |
| Constructor Detail |
|---|
public 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.| Method Detail |
|---|
public <T extends V> T put(K key,
T data)
CacheCache.putWithErrors(Object, Object) if you want to handle them.
put 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.
public final <T extends V> T putWithErrors(K key,
T data)
throws CacheException
Cache
putWithErrors 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
Cache
delete 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
Cache
cleanUp 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 <T extends V> T get(K key)
CacheCache.getWithErrors(Object) if you want to handle them.
get in interface Cache<K,V>key - The unique key under which the entry was stored.
public final <T extends V> T getWithErrors(K key)
throws CacheException
Cache
getWithErrors 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()
Cache
getStatistics in interface Cache<K,V>public ExpungeStrategy getExpungeStrategy()
public void setExpungeStrategy(ExpungeStrategy expungeStrategy)
protected void setEntriesMetaDataMap(Map<K,M> map)
protected Map<K,M> getEntriesMetaDataMap()
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
CacheException
protected abstract <T extends V> T doGet(K key,
M metaData)
throws CacheException
CacheException
protected abstract <T extends V> T doPut(K key,
T data)
throws CacheException
CacheException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||