public class NoopCache<K,V> extends Object implements CustomTtlCache<K,V>
UNLIMITED_IDLE_TIME| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Cleanup the cache.
|
void |
delete(K key)
Manually remove an entry from the cache.
|
V |
get(K key)
Retrieve an entry from the cache if it is available.
|
long |
getDefaultMaxIdleTime()
Get the default max idle time for cache entries.
|
long |
getDefaultTtl()
Retrieve the default time to live for cache entries.
|
MetaData |
getMetaData(K key)
Retrieve the
MetaData of a cached entry if it is available. |
String |
getName()
Get the name of this cache.
|
CacheStatistics |
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.
|
V |
put(K key,
V data,
long timeToLive)
Store an entry in the cache with a specific time to live.
|
V |
put(K key,
V data,
long timeToLive,
long maxIdleTime)
Store an entry in the cache with a specific time to live and max idle time.
|
void |
setDefaultTtl(long defaultTTL) |
void |
setName(String name) |
public NoopCache(String name)
public 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 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 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 void setDefaultTtl(long defaultTTL)
public long getDefaultTtl()
CachegetDefaultTtl in interface Cache<K,V>public 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 void cleanUp()
Cachepublic void setName(String name)
public String getName()
Cachepublic V put(K key, V data, long timeToLive) throws CacheException
CustomTtlCacheput in interface CustomTtlCache<K,V>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 entry instead.timeToLive - The time (in milliseconds) after which the entry expires.CacheException - Thrown if the storage fails.public CacheStatistics getStatistics()
CachegetStatistics in interface Cache<K,V>public long getDefaultMaxIdleTime()
CachegetDefaultMaxIdleTime in interface Cache<K,V>public V put(K key, V data, long timeToLive, long maxIdleTime) throws CacheException
CustomTtlCacheput in interface CustomTtlCache<K,V>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 entry instead.timeToLive - The time (in milliseconds) after which the entry expires.maxIdleTime - The time (in milliseconds) that an entry may idle (not being accessed) before
being expunged.CacheException - Thrown if the storage fails.Copyright © 2013 dontdrinkandroot. All Rights Reserved.