public class NoopCache<K,V> extends Object implements CustomTtlCache<K,V>
UNLIMITED_IDLE_TIME| Modifier and Type | Method and Description |
|---|---|
void |
cleanUp()
Removes expired and stale entries.
|
void |
delete(K key)
Manually remove an entry from the cache.
|
void |
expunge()
Cleanup the cache.
|
<T extends 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.
|
<T extends V> |
getWithErrors(K key)
Retrieve an entry from the cache if it is available.
|
<T extends V> |
put(K key,
T data)
Store an entry in the cache with the default time to live.
|
<T extends V> |
put(K key,
T data,
long timeToLive)
Store an entry in the cache with a specific time to live.
|
<T extends V> |
put(K key,
T data,
long timeToLive,
long maxIdleTime)
Store an entry in the cache with a specific time to live and max idle time.
|
<T extends V> |
putWithErrors(K key,
T data)
Store an entry in the cache with the default time to live.
|
<T extends V> |
putWithErrors(K key,
T data,
long timeToLive)
Store an entry in the cache with a specific time to live.
|
<T extends V> |
putWithErrors(K key,
T 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)
Sets the default time to live for cache entries.
|
void |
setName(String name) |
public NoopCache(String name)
public <T extends V> T putWithErrors(K key, T data) throws CacheException
CacheputWithErrors 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 <T extends V> T getWithErrors(K key) throws CacheException
CachegetWithErrors 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)
CachesetDefaultTtl in interface Cache<K,V>defaultTTL - The default time to live for a cache entry in milliseconds.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 expunge()
Cachepublic void setName(String name)
public String getName()
Cachepublic <T extends V> T putWithErrors(K key, T data, long timeToLive) throws CacheException
CustomTtlCacheputWithErrors 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 <T extends V> T putWithErrors(K key, T data, long timeToLive, long maxIdleTime) throws CacheException
CustomTtlCacheputWithErrors 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.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 <T extends V> T get(K key)
CacheCache.getWithErrors(Object) if you want to handle them.public <T extends V> T put(K key, T data, long timeToLive)
CustomTtlCacheCustomTtlCache.put(Object, Object, long) if you want to handle them.put 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.public <T extends V> T put(K key, T data, long timeToLive, long maxIdleTime)
CustomTtlCacheCustomTtlCache.putWithErrors(Object, Object, long) if you want to
handle them.put 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.public void cleanUp()
throws CacheException
CachecleanUp in interface Cache<K,V>CacheException - Thrown if the cleanup failed.Copyright © 2014 dontdrinkandroot. All rights reserved.