use of org.apache.archiva.redback.components.cache.Cache in project archiva by apache.
the class DefaultSystemStatusService method getCacheEntries.
@Override
public List<CacheEntry> getCacheEntries() throws ArchivaRestServiceException {
List<CacheEntry> cacheEntries = new ArrayList<CacheEntry>(caches.size());
DecimalFormat decimalFormat = new DecimalFormat("#%");
for (Map.Entry<String, Cache> entry : caches.entrySet()) {
CacheStatistics cacheStatistics = entry.getValue().getStatistics();
cacheEntries.add(new CacheEntry(entry.getKey(), cacheStatistics.getSize(), cacheStatistics.getCacheHits(), cacheStatistics.getCacheMiss(), decimalFormat.format(cacheStatistics.getCacheHitRate()).toString(), cacheStatistics.getInMemorySize()));
}
Collections.sort(cacheEntries, new CacheEntryComparator());
return cacheEntries;
}
use of org.apache.archiva.redback.components.cache.Cache in project archiva by apache.
the class DefaultSystemStatusService method clearCache.
@Override
public Boolean clearCache(String cacheKey) throws ArchivaRestServiceException {
Cache cache = caches.get(cacheKey);
if (cache == null) {
throw new ArchivaRestServiceException("no cache for key: " + cacheKey, Response.Status.BAD_REQUEST.getStatusCode(), null);
}
cache.clear();
return Boolean.TRUE;
}
Aggregations