0

I implemeted EHCache 3.10 statistics like this after looking at this post https://github.com/ehcache/ehcache3/issues/2951

StatisticsRetrieval statsRetrievalService = new StatisticsRetrieval();

try (CacheManager cacheManager = newCacheManagerBuilder()
  .withCache("foo", newCacheConfigurationBuilder(String.class, String.class, heap(1000)))
  .using(statsRetrievalService)
  .build(true)) {

  StatisticsService statisticsService = statsRetrievalService.getStatisticsService();

  Cache<String, String> cache = cacheManager.getCache("foo", String.class, String.class);
  cache.put("foo", "bar");
  cache.get("foo");

  CacheStatistics foobar = statisticsService.getCacheStatistics("foo");
  System.out.println(foobar.getCachePuts());
  System.out.println(foobar.getCacheGets());
}

But am stumped... Here are the statistics that I am getting.

cacheHitPercentage="0.0"
cacheMisses="0"
cacheRemovals="0"
cacheName="getOffersCache"
cacheMissPercentage="0.0"
cacheGets="255"
heapBytes="213315584"
cacheHits="0"
cachePuts="160"
cacheEvictions="0"
cacheExpirations="117937"

How is it possible to have 255 "cacheGets" and 0 "cacheHits" but have "cacheMisses=0" and "cacheMissPercentage=0.0"?

0 Answers0