AccumulationCache implements Accumulator { @Override public void put(HistogramKey key, @Nonnull AgentDigest value) { cache.asMap().compute(key, (k, v) -> { if (v == null) { if (cacheEnabled) cacheBinCreatedCounter.inc(); keyIndex.put(key, value.getDispatchTimeMillis()); return value; } else { if (cacheEnabled) cacheBinMergedCounter.inc(); keyIndex.compute(key, (k1, v1) -> ( v1 != null && v1 < v.getDispatchTimeMillis() ? v1 : v.getDispatchTimeMillis())); v.add(value); return v; } }); } AccumulationCache(
      final ConcurrentMap<HistogramKey, AgentDigest> backingStore,
      final AgentDigestFactory agentDigestFactory,
      final long cacheSize,
      String metricPrefix,
      @Nullable Ticker ticker); @VisibleForTesting protected  AccumulationCache(
      final ConcurrentMap<HistogramKey, AgentDigest> backingStore,
      final AgentDigestFactory agentDigestFactory,
      final long cacheSize,
      String metricPrefix,
      @Nullable Ticker ticker,
      @Nullable Runnable onFailure); @Override void put(HistogramKey key, @Nonnull AgentDigest value); @Override void put(HistogramKey key, double value); @Override void put(HistogramKey key, Histogram value); @Override Iterator<HistogramKey> getRipeDigestsIterator(TimeProvider clock); @Override AgentDigest compute(HistogramKey key, BiFunction<? super HistogramKey,? super AgentDigest,
      ? extends AgentDigest> remappingFunction); @Override long size(); @Override void flush();  }
@Test public void testAddCache() throws ExecutionException { cache.put(keyA, digestA); assertThat(cache.getIfPresent(keyA)).isEqualTo(digestA); assertThat(backingStore.get(keyA)).isNull(); }