@Service(value="cache#hashmap") public class HashMapCache<V,T> extends AbstractCache<V,T> implements Cache<V,T>
HashMapCache - this is a Cache implementation taken from the Archiva project.
Original class written by Edwin Punzalan for purposes of addressing the jira ticket MRM-39
Configure the refreshTime in seconds value configure a ttl of object life in cache. Object get( Object key ) :
Constructor and Description |
---|
HashMapCache() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Empty the cache and reset the cache hit rate
|
T |
get(V key)
Check for a cached object and return it if it exists.
|
double |
getCacheHitRatio() |
int |
getCacheMaxSize() |
int |
getRefreshTime() |
CacheStatistics |
getStatistics()
Obtain a set of Statistics about the performance of the cache.
|
org.apache.archiva.components.cache.hashmap.HashMapCache.Stats |
getStats() |
boolean |
hasKey(V key)
Check if the specified key is already mapped to an object.
|
void |
initialize() |
protected boolean |
isCacheAvailable() |
protected boolean |
needRefresh(CacheableWrapper cacheableWrapper) |
T |
put(V key,
T value)
Cache the given value and map it using the given key
|
void |
register(V key,
T value)
Cache the given value and map it using the given key
|
T |
remove(V key)
Remove the specified key and value from the cache.
|
void |
setCacheHitRatio(double cacheHitRatio) |
void |
setCacheMaxSize(int cacheMaxSize) |
void |
setRefreshTime(int refreshTime) |
getMaxElementsInMemory, getMaxElementsOnDisk, getTimeToIdleSeconds, getTimeToLiveSeconds, setMaxElementsInMemory, setMaxElementsOnDisk, setTimeToIdleSeconds, setTimeToLiveSeconds
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMaxElementsInMemory, getMaxElementsOnDisk, getTimeToIdleSeconds, getTimeToLiveSeconds, setMaxElementsInMemory, setMaxElementsOnDisk, setTimeToIdleSeconds, setTimeToLiveSeconds
public HashMapCache()
public void clear()
public T get(V key)
protected boolean needRefresh(CacheableWrapper cacheableWrapper)
public CacheStatistics getStatistics()
Cache
getStatistics
in interface Cache<V,T>
@PostConstruct public void initialize()
public T remove(V key)
Cache
public int getRefreshTime()
public void setRefreshTime(int refreshTime)
protected boolean isCacheAvailable()
public double getCacheHitRatio()
public void setCacheHitRatio(double cacheHitRatio)
public int getCacheMaxSize()
public void setCacheMaxSize(int cacheMaxSize)
public org.apache.archiva.components.cache.hashmap.HashMapCache.Stats getStats()
Copyright © 2006–2019 The Apache Software Foundation. All rights reserved.