public Map<String, Object> getCacheRuntimeInformationAsJson(Cache cache) { LinkedHashMap<String, Object> json = new LinkedHashMap<>(); StatisticsGateway statistics = cache.getStatistics(); json.put("Get Time in milliseconds", getStatisticsFrom(statistics.cacheGetOperation())); json.put("Put Time in milliseconds", getStatisticsFrom(statistics.cachePutOperation())); json.put("Remove Time in milliseconds", getStatisticsFrom(statistics.cacheRemoveOperation())); json.put("Cache Size", statistics.getSize()); LinkedHashMap<String, Long> cacheCount = new LinkedHashMap<>(); cacheCount.put("Hits", statistics.cacheHitCount()); cacheCount.put("Miss", statistics.cacheMissCount()); cacheCount.put("Expired", statistics.cacheExpiredCount()); cacheCount.put("Eviction", statistics.cacheEvictedCount()); cacheCount.put("Put", statistics.cachePutCount()); cacheCount.put("Remove", statistics.cacheRemoveCount()); json.put("Cache Counts", cacheCount); json.put("Cache Size (Disk)", statistics.getLocalDiskSize()); json.put("Cache Count (Disk)", statistics.localDiskHitCount()); return json; }
/** * {@inheritDoc} */ @Override public long getRemovedCount() { try { return cache.getStatistics().cacheRemoveCount(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
/** * {@inheritDoc} */ @Override public long getRemovedCount() { try { return cache.getStatistics().cacheRemoveCount(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
/** * {@inheritDoc} */ @Override public long getRemovedCount() { try { return cache.getStatistics().cacheRemoveCount(); } catch (RuntimeException e) { throw Utils.newPlainException(e); } }
@Override public long getCacheRemovals() { return getEhcache().getStatistics().cacheRemoveCount() - pCacheRemovals; }
@Override public long getCacheRemovals() { return getEhcache().getStatistics().cacheRemoveCount() - pCacheRemovals; }
@Override public void clear() { pCacheHits = getEhcache().getStatistics().cacheHitCount(); pCacheMisses = getEhcache().getStatistics().cacheMissCount(); pCacheGets = getEhcache().getStatistics().cacheGetOperation().count().value(); pCachePuts = getEhcache().getStatistics().cachePutCount(); pCacheRemovals = getEhcache().getStatistics().cacheRemoveCount(); pCacheEvictions = getEhcache().getStatistics().cacheEvictedCount(); }
@Override public void clear() { pCacheHits = getEhcache().getStatistics().cacheHitCount(); pCacheMisses = getEhcache().getStatistics().cacheMissCount(); pCacheGets = getEhcache().getStatistics().cacheGetOperation().count().value(); pCachePuts = getEhcache().getStatistics().cachePutCount(); pCacheRemovals = getEhcache().getStatistics().cacheRemoveCount(); pCacheEvictions = getEhcache().getStatistics().cacheEvictedCount(); }
public static SortedMap<CacheStatisticsKey, Supplier<Long>> toStatistics(final StatisticsGateway stats) { // Note: While most of these statistics we can reasonably expect to be cheap and just memoize, the // heap size in bytes is very likely to be expensive. To make it possible to opt out of retrieving // it, we hide it behind a Supplier, here. final Supplier<Long> heapSize = new Supplier<Long>() { @Override public Long get() { return stats.getLocalHeapSizeInBytes(); } }; return ImmutableSortedMap.<CacheStatisticsKey,Supplier<Long>>orderedBy(CacheStatisticsKey.SORT_BY_LABEL) .put(SIZE, memoize(stats.getSize())) .put(HEAP_SIZE, heapSize) .put(HIT_COUNT, memoize(stats.cacheHitCount())) .put(PUT_COUNT, memoize(stats.cachePutCount())) .put(REMOVE_COUNT, memoize(stats.cacheRemoveCount())) .put(MISS_COUNT, memoize(stats.cacheMissCount())) .put(EVICTION_COUNT, memoize(stats.cacheEvictedCount())) .build(); } }