com.github.benmanes.caffeine.cache.stats.CacheStats Java Examples

The following examples show how to use com.github.benmanes.caffeine.cache.stats.CacheStats. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CacheStatsTest.java    From caffeine with Apache License 2.0 6 votes vote down vote up
public void testPlus() {
  CacheStats one = new CacheStats(11, 13, 15, 13, 11, 9, 18);
  CacheStats two = new CacheStats(53, 47, 41, 39, 37, 35, 70);

  CacheStats sum = two.plus(one);
  assertEquals(124, sum.requestCount());
  assertEquals(64, sum.hitCount());
  assertEquals(64.0/124, sum.hitRate());
  assertEquals(60, sum.missCount());
  assertEquals(60.0/124, sum.missRate());
  assertEquals(56, sum.loadSuccessCount());
  assertEquals(52, sum.loadFailureCount());
  assertEquals(52.0/108, sum.loadFailureRate());
  assertEquals(56 + 52, sum.loadCount());
  assertEquals(48, sum.totalLoadTime());
  assertEquals(48.0/(56 + 52), sum.averageLoadPenalty());
  assertEquals(44, sum.evictionCount());
  assertEquals(88, sum.evictionWeight());

  assertEquals(sum, one.plus(two));
}
 
Example #2
Source File: CacheStatsTest.java    From caffeine with Apache License 2.0 6 votes vote down vote up
public void testSingle() {
  CacheStats stats = new CacheStats(11, 13, 17, 19, 23, 27, 54);
  assertEquals(24, stats.requestCount());
  assertEquals(11, stats.hitCount());
  assertEquals(11.0/24, stats.hitRate());
  assertEquals(13, stats.missCount());
  assertEquals(13.0/24, stats.missRate());
  assertEquals(17, stats.loadSuccessCount());
  assertEquals(19, stats.loadFailureCount());
  assertEquals(19.0/36, stats.loadFailureRate());
  assertEquals(17 + 19, stats.loadCount());
  assertEquals(23, stats.totalLoadTime());
  assertEquals(23.0/(17 + 19), stats.averageLoadPenalty());
  assertEquals(27, stats.evictionCount());
  assertEquals(54, stats.evictionWeight());
}
 
Example #3
Source File: HasStats.java    From caffeine with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean matchesSafely(CacheContext context, Description description) {
  if (!context.isRecordingStats()) {
    return true;
  }

  CacheStats stats = context.stats();
  desc = new DescriptionBuilder(description);
  ForkJoinPool.commonPool().awaitQuiescence(10, TimeUnit.SECONDS);
  switch (type) {
    case HIT:
      return desc.expectThat(type.name(), stats.hitCount(), is(count)).matches();
    case MISS:
      return desc.expectThat(type.name(), stats.missCount(), is(count)).matches();
    case EVICTION_COUNT:
      return desc.expectThat(type.name(), stats.evictionCount(), is(count)).matches();
    case EVICTION_WEIGHT:
      return desc.expectThat(type.name(), stats.evictionWeight(), is(count)).matches();
    case LOAD_SUCCESS:
      return desc.expectThat(type.name(), stats.loadSuccessCount(), is(count)).matches();
    case LOAD_FAILURE:
      return desc.expectThat(type.name(), stats.loadFailureCount(), is(count)).matches();
    default:
      throw new AssertionError("Unknown stats type");
  }
}
 
Example #4
Source File: CacheStatsTest.java    From caffeine with Apache License 2.0 6 votes vote down vote up
public void testMinus() {
  CacheStats one = new CacheStats(11, 13, 17, 19, 23, 27, 54);
  CacheStats two = new CacheStats(53, 47, 43, 41, 37, 31, 62);

  CacheStats diff = two.minus(one);
  assertEquals(76, diff.requestCount());
  assertEquals(42, diff.hitCount());
  assertEquals(42.0/76, diff.hitRate());
  assertEquals(34, diff.missCount());
  assertEquals(34.0/76, diff.missRate());
  assertEquals(26, diff.loadSuccessCount());
  assertEquals(22, diff.loadFailureCount());
  assertEquals(22.0/48, diff.loadFailureRate());
  assertEquals(26 + 22, diff.loadCount());
  assertEquals(14, diff.totalLoadTime());
  assertEquals(14.0/(26 + 22), diff.averageLoadPenalty());
  assertEquals(4, diff.evictionCount());
  assertEquals(8, diff.evictionWeight());

  assertEquals(new CacheStats(0, 0, 0, 0, 0, 0, 0), one.minus(two));
}
 
Example #5
Source File: InstrumentedCache.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
private void updateMetrics() {
    CacheStats currentStatsSnapshot = cache.stats();
    if (lastStatsSnapshot != null) {
        CacheStats statsDifference = currentStatsSnapshot.minus(lastStatsSnapshot);
        requestCountGauge.set(statsDifference.requestCount());
        hitCountGauge.set(statsDifference.hitCount());
        missCountGauge.set(statsDifference.missCount());
        loadSuccessCountGauge.set(statsDifference.loadSuccessCount());
        loadFailureCountGauge.set(statsDifference.loadFailureCount());
        totalLoadTimeGauge.set(statsDifference.totalLoadTime());
        evictionCountGauge.set(statsDifference.evictionCount());
        evictionWeightGauge.set(statsDifference.evictionWeight());
    }
    estimatedSizeGauge.set(estimatedSize());
    lastStatsSnapshot = currentStatsSnapshot;
}
 
Example #6
Source File: CaffeineCacheMetricsTest.java    From micrometer with Apache License 2.0 6 votes vote down vote up
@Test
void reportExpectedGeneralMetrics() {
    MeterRegistry registry = new SimpleMeterRegistry();
    metrics.bindTo(registry);

    verifyCommonCacheMetrics(registry, metrics);

    FunctionCounter evictionWeight = fetch(registry, "cache.eviction.weight").functionCounter();
    CacheStats stats = cache.stats();
    assertThat(evictionWeight.count()).isEqualTo(stats.evictionWeight());

    // specific to LoadingCache instance
    TimeGauge loadDuration = fetch(registry, "cache.load.duration").timeGauge();
    assertThat(loadDuration.value()).isEqualTo(stats.totalLoadTime());

    FunctionCounter successfulLoad = fetch(registry, "cache.load", Tags.of("result", "success")).functionCounter();
    assertThat(successfulLoad.count()).isEqualTo(stats.loadSuccessCount());

    FunctionCounter failedLoad = fetch(registry, "cache.load", Tags.of("result", "failure")).functionCounter();
    assertThat(failedLoad.count()).isEqualTo(stats.loadFailureCount());
}
 
Example #7
Source File: CacheStatsSerializer.java    From centraldogma with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(CacheStats value, JsonGenerator gen, SerializerProvider provider) throws IOException {
    gen.writeStartObject();
    gen.writeNumberField("requestCount", value.requestCount());
    gen.writeNumberField("hitCount", value.hitCount());
    gen.writeNumberField("hitRate", value.hitRate());
    gen.writeNumberField("missCount", value.missCount());
    gen.writeNumberField("missRate", value.missRate());
    gen.writeNumberField("loadCount", value.loadCount());
    gen.writeNumberField("loadSuccessCount", value.loadSuccessCount());
    gen.writeNumberField("loadFailureCount", value.loadFailureCount());
    gen.writeNumberField("loadFailureRate", value.loadFailureRate());
    gen.writeNumberField("totalLoadTime", value.totalLoadTime());
    gen.writeNumberField("averageLoadPenalty", value.averageLoadPenalty());
    gen.writeNumberField("evictionCount", value.evictionCount());
    gen.writeNumberField("evictionWeight", value.evictionWeight());
    gen.writeEndObject();
}
 
Example #8
Source File: MetricsStatsCounter.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public CacheStats snapshot() {
    return new CacheStats(
            hitCount.getCount(),
            missCount.getCount(),
            loadSuccessCount.getCount(),
            loadFailureCount.getCount(),
            Arrays.stream(totalLoadTime.getRecords()).mapToLong(Long::longValue).sum(),
            evictionCount.getCount(),
            evictionWeight.getCount());
}
 
Example #9
Source File: CaffeineStatsCounter.java    From kork with Apache License 2.0 5 votes vote down vote up
@Override
public CacheStats snapshot() {
  return new CacheStats(
      hitCount.count(),
      missCount.count(),
      loadSuccessCount.count(),
      loadFailureCount.count(),
      totalLoadTime.count(),
      evictionCount.count(),
      evictionWeight.count());
}
 
Example #10
Source File: CaffeineCache.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeMetrics(SolrMetricsContext parentContext, String scope) {
  solrMetricsContext = parentContext.getChildContext(this);
  cacheMap = new MetricsMap((detailed, map) -> {
    if (cache != null) {
      CacheStats stats = cache.stats();
      long insertCount = inserts.sum();

      map.put(LOOKUPS_PARAM, stats.requestCount());
      map.put(HITS_PARAM, stats.hitCount());
      map.put(HIT_RATIO_PARAM, stats.hitRate());
      map.put(INSERTS_PARAM, insertCount);
      map.put(EVICTIONS_PARAM, stats.evictionCount());
      map.put(SIZE_PARAM, cache.asMap().size());
      map.put("warmupTime", warmupTime);
      map.put(RAM_BYTES_USED_PARAM, ramBytesUsed());
      map.put(MAX_RAM_MB_PARAM, getMaxRamMB());

      CacheStats cumulativeStats = priorStats.plus(stats);
      map.put("cumulative_lookups", cumulativeStats.requestCount());
      map.put("cumulative_hits", cumulativeStats.hitCount());
      map.put("cumulative_hitratio", cumulativeStats.hitRate());
      map.put("cumulative_inserts", priorInserts + insertCount);
      map.put("cumulative_evictions", cumulativeStats.evictionCount());
    }
  });
  solrMetricsContext.gauge(cacheMap, true, scope, getCategory().toString());
}
 
Example #11
Source File: CaffeineMetricSupport.java    From armeria with Apache License 2.0 5 votes vote down vote up
private ToDoubleFunction<CaffeineMetrics> func(@Nullable Type type,
                                               ToDoubleFunction<CacheReference> valueFunction) {
    return value -> {
        double sum = 0;
        synchronized (cacheRefs) {
            for (final Iterator<CacheReference> i = cacheRefs.iterator(); i.hasNext();) {
                final CacheReference ref = i.next();
                final boolean garbageCollected = ref.updateCacheStats();
                if (!garbageCollected) {
                    sum += valueFunction.applyAsDouble(ref);
                } else {
                    // Remove the garbage-collected reference from the list to prevent it from
                    // growing infinitely.
                    i.remove();

                    // Accumulate the stats of the removed reference so the counters do not decrease.
                    // NB: We do not accumulate 'estimatedSize' because it's not a counter but a gauge.
                    final CacheStats stats = ref.cacheStats;
                    statsForGarbageCollected[HIT_COUNT.ordinal()] += stats.hitCount();
                    statsForGarbageCollected[MISS_COUNT.ordinal()] += stats.missCount();
                    statsForGarbageCollected[EVICTION_COUNT.ordinal()] += stats.evictionCount();
                    statsForGarbageCollected[EVICTION_WEIGHT.ordinal()] += stats.evictionWeight();
                    statsForGarbageCollected[LOAD_SUCCESS_COUNT.ordinal()] += stats.loadSuccessCount();
                    statsForGarbageCollected[LOAD_FAILURE_COUNT.ordinal()] += stats.loadFailureCount();
                    statsForGarbageCollected[TOTAL_LOAD_TIME.ordinal()] += stats.totalLoadTime();
                }
            }

            if (type != null) {
                // Add the value of the garbage-collected caches.
                sum += statsForGarbageCollected[type.ordinal()];
            }
        }

        return sum;
    };
}
 
Example #12
Source File: CacheStatsTest.java    From caffeine with Apache License 2.0 5 votes vote down vote up
public void testEmpty() {
  CacheStats stats = new CacheStats(0, 0, 0, 0, 0, 0, 0);
  assertEquals(0, stats.requestCount());
  assertEquals(0, stats.hitCount());
  assertEquals(1.0, stats.hitRate());
  assertEquals(0, stats.missCount());
  assertEquals(0.0, stats.missRate());
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadFailureCount());
  assertEquals(0.0, stats.loadFailureRate());
  assertEquals(0, stats.loadCount());
  assertEquals(0, stats.totalLoadTime());
  assertEquals(0.0, stats.averageLoadPenalty());
  assertEquals(0, stats.evictionCount());
}
 
Example #13
Source File: MetricsStatsCounter.java    From caffeine with Apache License 2.0 5 votes vote down vote up
@Override
public CacheStats snapshot() {
  return new CacheStats(
      hitCount.getCount(),
      missCount.getCount(),
      loadSuccessCount.getCount(),
      loadFailureCount.getCount(),
      totalLoadTime.getCount(),
      evictionCount.getCount(),
      evictionWeight.getCount());
}
 
Example #14
Source File: AbstractCacheTest.java    From caffeine with Apache License 2.0 5 votes vote down vote up
public void testEmptySimpleStats() {
  StatsCounter counter = new ConcurrentStatsCounter();
  CacheStats stats = counter.snapshot();
  assertEquals(0, stats.requestCount());
  assertEquals(0, stats.hitCount());
  assertEquals(1.0, stats.hitRate(), 0.0);
  assertEquals(0, stats.missCount());
  assertEquals(0.0, stats.missRate(), 0.0);
  assertEquals(0, stats.loadSuccessCount());
  assertEquals(0, stats.loadFailureCount());
  assertEquals(0, stats.loadCount());
  assertEquals(0, stats.totalLoadTime());
  assertEquals(0.0, stats.averageLoadPenalty(), 0.0);
  assertEquals(0, stats.evictionCount());
}
 
Example #15
Source File: AbstractCacheTest.java    From caffeine with Apache License 2.0 5 votes vote down vote up
public void testSingleSimpleStats() {
  StatsCounter counter = new ConcurrentStatsCounter();
  for (int i = 0; i < 11; i++) {
    counter.recordHits(1);
  }
  for (int i = 0; i < 13; i++) {
    counter.recordLoadSuccess(i);
  }
  for (int i = 0; i < 17; i++) {
    counter.recordLoadFailure(i);
  }
  for (int i = 0; i < 23; i++) {
    counter.recordMisses(1);
  }
  for (int i = 0; i < 27; i++) {
    counter.recordEviction(1, RemovalCause.SIZE);
  }
  CacheStats stats = counter.snapshot();
  int requestCount = 11 + 23;
  assertEquals(requestCount, stats.requestCount());
  assertEquals(11, stats.hitCount());
  assertEquals(11.0 / requestCount, stats.hitRate(), 0.0);
  int missCount = 23;
  assertEquals(missCount, stats.missCount());
  assertEquals(((double) missCount) / requestCount, stats.missRate(), 0.0);
  assertEquals(13, stats.loadSuccessCount());
  assertEquals(17, stats.loadFailureCount());
  assertEquals(13 + 17, stats.loadCount());
  assertEquals(214, stats.totalLoadTime());
  assertEquals(214.0 / (13 + 17), stats.averageLoadPenalty(), 0.0);
  assertEquals(27, stats.evictionCount());
}
 
Example #16
Source File: AbstractCacheTest.java    From caffeine with Apache License 2.0 5 votes vote down vote up
public void testSimpleStatsOverflow() {
  StatsCounter counter = new ConcurrentStatsCounter();
  counter.recordLoadSuccess(Long.MAX_VALUE);
  counter.recordLoadSuccess(1);
  CacheStats stats = counter.snapshot();
  assertEquals(Long.MAX_VALUE, stats.totalLoadTime());
}
 
Example #17
Source File: CacheStatsTest.java    From caffeine with Apache License 2.0 5 votes vote down vote up
public void testPlusLarge() {
  CacheStats maxCacheStats =
      new CacheStats(
          Long.MAX_VALUE,
          Long.MAX_VALUE,
          Long.MAX_VALUE,
          Long.MAX_VALUE,
          Long.MAX_VALUE,
          Long.MAX_VALUE,
          Long.MAX_VALUE);
  CacheStats smallCacheStats = new CacheStats(1, 1, 1, 1, 1, 1, 1);

  CacheStats sum = smallCacheStats.plus(maxCacheStats);
  assertEquals(Long.MAX_VALUE, sum.requestCount());
  assertEquals(Long.MAX_VALUE, sum.hitCount());
  assertEquals(1.0, sum.hitRate());
  assertEquals(Long.MAX_VALUE, sum.missCount());
  assertEquals(1.0, sum.missRate());
  assertEquals(Long.MAX_VALUE, sum.loadSuccessCount());
  assertEquals(Long.MAX_VALUE, sum.loadFailureCount());
  assertEquals(1.0, sum.loadFailureRate());
  assertEquals(Long.MAX_VALUE, sum.loadCount());
  assertEquals(Long.MAX_VALUE, sum.totalLoadTime());
  assertEquals(1.0, sum.averageLoadPenalty());
  assertEquals(Long.MAX_VALUE, sum.evictionCount());
  assertEquals(Long.MAX_VALUE, sum.evictionWeight());

  assertEquals(sum, maxCacheStats.plus(smallCacheStats));
}
 
Example #18
Source File: LocalAsyncCache.java    From caffeine with Apache License 2.0 4 votes vote down vote up
@Override
public CacheStats stats() {
  return asyncCache().cache().statsCounter().snapshot();
}
 
Example #19
Source File: LocalManualCache.java    From caffeine with Apache License 2.0 4 votes vote down vote up
@Override
default CacheStats stats() {
  return cache().statsCounter().snapshot();
}
 
Example #20
Source File: MetricsStatsCounter.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Override
public CacheStats snapshot() {
    return new CacheStats(hitCount.getCount(), missCount.getCount(), loadSuccessCount.getCount(), loadFailureCount.getCount(), totalLoadTime.getCount(),
                          evictionCount.getCount(), evictionWeight.getCount());
}
 
Example #21
Source File: CacheContext.java    From caffeine with Apache License 2.0 4 votes vote down vote up
public CacheStats stats() {
  return cache.stats();
}
 
Example #22
Source File: CacheMetricsCollector.java    From client_java with Apache License 2.0 4 votes vote down vote up
@Override
public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>();
    List<String> labelNames = Arrays.asList("cache");

    CounterMetricFamily cacheHitTotal = new CounterMetricFamily("caffeine_cache_hit_total",
            "Cache hit totals", labelNames);
    mfs.add(cacheHitTotal);

    CounterMetricFamily cacheMissTotal = new CounterMetricFamily("caffeine_cache_miss_total",
            "Cache miss totals", labelNames);
    mfs.add(cacheMissTotal);

    CounterMetricFamily cacheRequestsTotal = new CounterMetricFamily("caffeine_cache_requests_total",
            "Cache request totals, hits + misses", labelNames);
    mfs.add(cacheRequestsTotal);

    CounterMetricFamily cacheEvictionTotal = new CounterMetricFamily("caffeine_cache_eviction_total",
            "Cache eviction totals, doesn't include manually removed entries", labelNames);
    mfs.add(cacheEvictionTotal);

    GaugeMetricFamily cacheEvictionWeight = new GaugeMetricFamily("caffeine_cache_eviction_weight",
            "Cache eviction weight", labelNames);
    mfs.add(cacheEvictionWeight);

    CounterMetricFamily cacheLoadFailure = new CounterMetricFamily("caffeine_cache_load_failure_total",
            "Cache load failures", labelNames);
    mfs.add(cacheLoadFailure);

    CounterMetricFamily cacheLoadTotal = new CounterMetricFamily("caffeine_cache_loads_total",
            "Cache loads: both success and failures", labelNames);
    mfs.add(cacheLoadTotal);

    GaugeMetricFamily cacheSize = new GaugeMetricFamily("caffeine_cache_estimated_size",
            "Estimated cache size", labelNames);
    mfs.add(cacheSize);

    SummaryMetricFamily cacheLoadSummary = new SummaryMetricFamily("caffeine_cache_load_duration_seconds",
            "Cache load duration: both success and failures", labelNames);
    mfs.add(cacheLoadSummary);

    for(Map.Entry<String, Cache> c: children.entrySet()) {
        List<String> cacheName = Arrays.asList(c.getKey());
        CacheStats stats = c.getValue().stats();

        try{
            cacheEvictionWeight.addMetric(cacheName, stats.evictionWeight());
        } catch (Exception e) {
            // EvictionWeight metric is unavailable, newer version of Caffeine is needed.
        }

        cacheHitTotal.addMetric(cacheName, stats.hitCount());
        cacheMissTotal.addMetric(cacheName, stats.missCount());
        cacheRequestsTotal.addMetric(cacheName, stats.requestCount());
        cacheEvictionTotal.addMetric(cacheName, stats.evictionCount());
        cacheSize.addMetric(cacheName, c.getValue().estimatedSize());

        if(c.getValue() instanceof LoadingCache) {
            cacheLoadFailure.addMetric(cacheName, stats.loadFailureCount());
            cacheLoadTotal.addMetric(cacheName, stats.loadCount());

            cacheLoadSummary.addMetric(cacheName, stats.loadCount(), stats.totalLoadTime() / Collector.NANOSECONDS_PER_SECOND);
        }
    }
    return mfs;
}
 
Example #23
Source File: AbstractCacheTest.java    From caffeine with Apache License 2.0 4 votes vote down vote up
public void testSimpleStatsIncrementBy() {
  long totalLoadTime = 0;

  ConcurrentStatsCounter counter1 = new ConcurrentStatsCounter();
  for (int i = 0; i < 11; i++) {
    counter1.recordHits(1);
  }
  for (int i = 0; i < 13; i++) {
    counter1.recordLoadSuccess(i);
    totalLoadTime += i;
  }
  for (int i = 0; i < 17; i++) {
    counter1.recordLoadFailure(i);
    totalLoadTime += i;
  }
  for (int i = 0; i < 19; i++) {
    counter1.recordMisses(1);
  }
  for (int i = 0; i < 23; i++) {
    counter1.recordEviction(1, RemovalCause.SIZE);
  }

  ConcurrentStatsCounter counter2 = new ConcurrentStatsCounter();
  for (int i = 0; i < 27; i++) {
    counter2.recordHits(1);
  }
  for (int i = 0; i < 31; i++) {
    counter2.recordLoadSuccess(i);
    totalLoadTime += i;
  }
  for (int i = 0; i < 37; i++) {
    counter2.recordLoadFailure(i);
    totalLoadTime += i;
  }
  for (int i = 0; i < 41; i++) {
    counter2.recordMisses(1);
  }
  for (int i = 0; i < 43; i++) {
    counter1.recordEviction(1, RemovalCause.SIZE);
  }

  counter1.incrementBy(counter2);
  assertEquals(new CacheStats(38, 60, 44, 54, totalLoadTime, 66, 66), counter1.snapshot());
}
 
Example #24
Source File: CaffeineMetricSupportTest.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public CacheStats stats() {
    statsCalls++;
    return stats;
}
 
Example #25
Source File: CaffeineMetricSupportTest.java    From armeria with Apache License 2.0 4 votes vote down vote up
void update(long hitCount, long missCount, long loadSuccessCount, long loadFailureCount,
            long totalLoadTime, long evictionCount, long evictionWeight, long estimatedSize) {
    stats = new CacheStats(hitCount, missCount, loadSuccessCount, loadFailureCount,
                           totalLoadTime, evictionCount, evictionWeight);
    this.estimatedSize = estimatedSize;
}
 
Example #26
Source File: MetricReportingCache.java    From cerberus with Apache License 2.0 4 votes vote down vote up
@Override
public CacheStats stats() {
  return delegate.stats();
}
 
Example #27
Source File: CaffeineCache.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public CaffeineCache() {
  this.priorStats = CacheStats.empty();
}
 
Example #28
Source File: RepositoryCache.java    From centraldogma with Apache License 2.0 4 votes vote down vote up
public CacheStats stats() {
    return cache.synchronous().stats();
}
 
Example #29
Source File: CacheStatsSerializer.java    From centraldogma with Apache License 2.0 4 votes vote down vote up
CacheStatsSerializer() {
    super(CacheStats.class);
}
 
Example #30
Source File: CaffeineImpl.java    From RxCache with Apache License 2.0 3 votes vote down vote up
public CacheStatistics getCacheStatistics() {

        CacheStats cacheStats = cache.stats();

        long evictionCount = cacheStats.evictionCount();
        long hitCount = cacheStats.hitCount();
        long missCount = cacheStats.missCount();

        return new CacheStatistics((int)maxSize,putCount.get(),(int)evictionCount,(int)hitCount,(int)missCount);
    }