Codota Logo
CacheStats.missCount
Code IndexAdd Codota to your IDE (free)

How to use
missCount
method
in
com.google.common.cache.CacheStats

Best Java code snippets using com.google.common.cache.CacheStats.missCount (Showing top 20 results out of 558)

  • Common ways to obtain CacheStats
private void myMethod () {
CacheStats c =
  • Codota IconLoadingCache cache;cache.stats()
  • Codota IconCache cache;cache.stats()
  • Codota IconForwardingCache forwardingCache;forwardingCache.delegate().stats()
  • Smart code suggestions by Codota
}
origin: google/guava

public void testPutAll_populated() {
 for (LoadingCache<Object, Object> cache : caches()) {
  // don't let the entries get GCed
  List<Entry<Object, Object>> warmed = warmUp(cache);
  Object newKey = new Object();
  Object newValue = new Object();
  cache.asMap().putAll(ImmutableMap.of(newKey, newValue));
  // this getUnchecked() call shouldn't be a cache miss; verified below
  assertEquals(newValue, cache.getUnchecked(newKey));
  assertEquals(WARMUP_SIZE, cache.stats().missCount());
  checkValidState(cache);
 }
}
origin: google/guava

public void testReplace_populated() {
 for (LoadingCache<Object, Object> cache : caches()) {
  // don't let the entries get GCed
  List<Entry<Object, Object>> warmed = warmUp(cache);
  for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
   Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
   Object newValue = new Object();
   assertSame(entry.getValue(), cache.asMap().replace(entry.getKey(), newValue));
   assertTrue(cache.asMap().replace(entry.getKey(), newValue, entry.getValue()));
   Object newKey = new Object();
   assertNull(cache.asMap().replace(newKey, entry.getValue()));
   assertFalse(cache.asMap().replace(newKey, entry.getValue(), newValue));
   // this getUnchecked() call shouldn't be a cache miss; verified below
   assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
   assertFalse(cache.asMap().containsKey(newKey));
  }
  assertEquals(WARMUP_SIZE, cache.stats().missCount());
  checkValidState(cache);
 }
}
origin: google/guava

public void testPutIfAbsent_populated() {
 for (LoadingCache<Object, Object> cache : caches()) {
  // don't let the entries get GCed
  List<Entry<Object, Object>> warmed = warmUp(cache);
  for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
   Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
   Object newValue = new Object();
   assertSame(entry.getValue(), cache.asMap().putIfAbsent(entry.getKey(), newValue));
   Object newKey = new Object();
   assertNull(cache.asMap().putIfAbsent(newKey, entry.getValue()));
   // this getUnchecked() call shouldn't be a cache miss; verified below
   assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
   assertEquals(entry.getValue(), cache.getUnchecked(newKey));
   // don't let the new entry get GCed
   warmed.add(entryOf(newKey, entry.getValue()));
  }
  assertEquals(WARMUP_SIZE, cache.stats().missCount());
  checkValidState(cache);
 }
}
origin: google/guava

public void testContainsKey_found() {
 for (LoadingCache<Object, Object> cache : caches()) {
  // don't let the entries get GCed
  List<Entry<Object, Object>> warmed = warmUp(cache);
  for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
   Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
   assertTrue(cache.asMap().containsKey(entry.getKey()));
   assertTrue(cache.asMap().containsValue(entry.getValue()));
   // this getUnchecked() call shouldn't be a cache miss; verified below
   assertEquals(entry.getValue(), cache.getUnchecked(entry.getKey()));
  }
  assertEquals(WARMUP_SIZE, cache.stats().missCount());
  checkValidState(cache);
 }
}
origin: google/guava

public void testPut_populated() {
 for (LoadingCache<Object, Object> cache : caches()) {
  // don't let the entries get GCed
  List<Entry<Object, Object>> warmed = warmUp(cache);
  for (int i = WARMUP_MIN; i < WARMUP_MAX; i++) {
   Entry<Object, Object> entry = warmed.get(i - WARMUP_MIN);
   Object newValue = new Object();
   assertSame(entry.getValue(), cache.asMap().put(entry.getKey(), newValue));
   // don't let the new entry get GCed
   warmed.add(entryOf(entry.getKey(), newValue));
   Object newKey = new Object();
   assertNull(cache.asMap().put(newKey, entry.getValue()));
   // this getUnchecked() call shouldn't be a cache miss; verified below
   assertEquals(newValue, cache.getUnchecked(entry.getKey()));
   assertEquals(entry.getValue(), cache.getUnchecked(newKey));
   // don't let the new entry get GCed
   warmed.add(entryOf(newKey, entry.getValue()));
  }
  assertEquals(WARMUP_SIZE, cache.stats().missCount());
  checkValidState(cache);
 }
}
origin: apache/incubator-druid

@Override
public LookupCacheStats getStats()
{
 return new LookupCacheStats(
   cache.stats().hitCount(),
   cache.stats().missCount(),
   cache.stats().evictionCount()
 );
}
origin: google/guava

 /** Increments all counters by the values in {@code other}. */
 public void incrementBy(StatsCounter other) {
  CacheStats otherStats = other.snapshot();
  hitCount.add(otherStats.hitCount());
  missCount.add(otherStats.missCount());
  loadSuccessCount.add(otherStats.loadSuccessCount());
  loadExceptionCount.add(otherStats.loadExceptionCount());
  totalLoadTime.add(otherStats.totalLoadTime());
  evictionCount.add(otherStats.evictionCount());
 }
}
origin: google/guava

public void testBulkLoadInterruptedException() {
 Exception e = new InterruptedException();
 CacheLoader<Object, Object> loader = exceptionLoader(e);
 LoadingCache<Object, Object> cache =
   CacheBuilder.newBuilder().recordStats().build(bulkLoader(loader));
 CacheStats stats = cache.stats();
 assertEquals(0, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(0, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
 try {
  cache.getAll(asList(new Object()));
  fail();
 } catch (ExecutionException expected) {
  assertThat(expected).hasCauseThat().isSameAs(e);
 }
 assertTrue(currentThread().interrupted());
 stats = cache.stats();
 assertEquals(1, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(1, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
}
origin: google/guava

public void testBulkLoadCheckedException() {
 Exception e = new Exception();
 CacheLoader<Object, Object> loader = exceptionLoader(e);
 LoadingCache<Object, Object> cache =
   CacheBuilder.newBuilder().recordStats().build(bulkLoader(loader));
 CacheStats stats = cache.stats();
 assertEquals(0, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(0, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
 try {
  cache.getAll(asList(new Object()));
  fail();
 } catch (ExecutionException expected) {
  assertThat(expected).hasCauseThat().isSameAs(e);
 }
 stats = cache.stats();
 assertEquals(1, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(1, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
}
origin: google/guava

public void testRecordStats() {
 CacheBuilder<Object, Object> builder =
   createCacheBuilder().recordStats().concurrencyLevel(1).maximumSize(2);
 LocalLoadingCache<Object, Object> cache = makeCache(builder, identityLoader());
 assertEquals(0, cache.stats().hitCount());
 assertEquals(0, cache.stats().missCount());
 Object one = new Object();
 cache.getUnchecked(one);
 assertEquals(0, cache.stats().hitCount());
 assertEquals(1, cache.stats().missCount());
 cache.getUnchecked(one);
 assertEquals(1, cache.stats().hitCount());
 assertEquals(1, cache.stats().missCount());
 Object two = new Object();
 cache.getUnchecked(two);
 assertEquals(1, cache.stats().hitCount());
 assertEquals(2, cache.stats().missCount());
 Object three = new Object();
 cache.getUnchecked(three);
 assertEquals(1, cache.stats().hitCount());
 assertEquals(3, cache.stats().missCount());
}
origin: google/guava

public void testBulkLoadError() throws ExecutionException {
 Error e = new Error();
 CacheLoader<Object, Object> loader = errorLoader(e);
 LoadingCache<Object, Object> cache =
   CacheBuilder.newBuilder().recordStats().build(bulkLoader(loader));
 CacheStats stats = cache.stats();
 assertEquals(0, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(0, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
 try {
  cache.getAll(asList(new Object()));
  fail();
 } catch (ExecutionError expected) {
  assertThat(expected).hasCauseThat().isSameAs(e);
 }
 stats = cache.stats();
 assertEquals(1, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(1, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
}
origin: google/guava

public void testBulkLoadUncheckedException() throws ExecutionException {
 Exception e = new RuntimeException();
 CacheLoader<Object, Object> loader = exceptionLoader(e);
 LoadingCache<Object, Object> cache =
   CacheBuilder.newBuilder().recordStats().build(bulkLoader(loader));
 CacheStats stats = cache.stats();
 assertEquals(0, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(0, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
 try {
  cache.getAll(asList(new Object()));
  fail();
 } catch (UncheckedExecutionException expected) {
  assertThat(expected).hasCauseThat().isSameAs(e);
 }
 stats = cache.stats();
 assertEquals(1, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(1, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
}
origin: google/guava

public void testBulkLoadNull() throws ExecutionException {
 LoadingCache<Object, Object> cache =
   CacheBuilder.newBuilder().recordStats().build(bulkLoader(constantLoader(null)));
 CacheStats stats = cache.stats();
 assertEquals(0, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(0, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
 try {
  cache.getAll(asList(new Object()));
  fail();
 } catch (InvalidCacheLoadException expected) {
 }
 stats = cache.stats();
 assertEquals(1, stats.missCount());
 assertEquals(0, stats.loadSuccessCount());
 assertEquals(1, stats.loadExceptionCount());
 assertEquals(0, stats.hitCount());
}
origin: google/j2objc

 /** Increments all counters by the values in {@code other}. */
 public void incrementBy(StatsCounter other) {
  CacheStats otherStats = other.snapshot();
  hitCount.add(otherStats.hitCount());
  missCount.add(otherStats.missCount());
  loadSuccessCount.add(otherStats.loadSuccessCount());
  loadExceptionCount.add(otherStats.loadExceptionCount());
  totalLoadTime.add(otherStats.totalLoadTime());
  evictionCount.add(otherStats.evictionCount());
 }
}
origin: google/guava

public void testEmptySimpleStats() {
 StatsCounter counter = new SimpleStatsCounter();
 CacheStats stats = counter.snapshot();
 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.loadExceptionCount());
 assertEquals(0, stats.loadCount());
 assertEquals(0, stats.totalLoadTime());
 assertEquals(0.0, stats.averageLoadPenalty());
 assertEquals(0, stats.evictionCount());
}
origin: google/guava

public void testEmpty() {
 CacheStats stats = new CacheStats(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.loadExceptionCount());
 assertEquals(0.0, stats.loadExceptionRate());
 assertEquals(0, stats.loadCount());
 assertEquals(0, stats.totalLoadTime());
 assertEquals(0.0, stats.averageLoadPenalty());
 assertEquals(0, stats.evictionCount());
}
origin: google/guava

public void testSingle() {
 CacheStats stats = new CacheStats(11, 13, 17, 19, 23, 27);
 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.loadExceptionCount());
 assertEquals(19.0 / 36, stats.loadExceptionRate());
 assertEquals(17 + 19, stats.loadCount());
 assertEquals(23, stats.totalLoadTime());
 assertEquals(23.0 / (17 + 19), stats.averageLoadPenalty());
 assertEquals(27, stats.evictionCount());
}
origin: google/guava

 public void testPlus() {
  CacheStats one = new CacheStats(11, 13, 15, 13, 11, 9);
  CacheStats two = new CacheStats(53, 47, 41, 39, 37, 35);

  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.loadExceptionCount());
  assertEquals(52.0 / 108, sum.loadExceptionRate());
  assertEquals(56 + 52, sum.loadCount());
  assertEquals(48, sum.totalLoadTime());
  assertEquals(48.0 / (56 + 52), sum.averageLoadPenalty());
  assertEquals(44, sum.evictionCount());

  assertEquals(sum, one.plus(two));
 }
}
origin: google/guava

public void testMinus() {
 CacheStats one = new CacheStats(11, 13, 17, 19, 23, 27);
 CacheStats two = new CacheStats(53, 47, 43, 41, 37, 31);
 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.loadExceptionCount());
 assertEquals(22.0 / 48, diff.loadExceptionRate());
 assertEquals(26 + 22, diff.loadCount());
 assertEquals(14, diff.totalLoadTime());
 assertEquals(14.0 / (26 + 22), diff.averageLoadPenalty());
 assertEquals(4, diff.evictionCount());
 assertEquals(new CacheStats(0, 0, 0, 0, 0, 0), one.minus(two));
}
origin: google/guava

assertEquals(11.0 / requestCount, stats.hitRate());
int missCount = 23;
assertEquals(missCount, stats.missCount());
assertEquals(((double) missCount) / requestCount, stats.missRate());
assertEquals(13, stats.loadSuccessCount());
com.google.common.cacheCacheStatsmissCount

Javadoc

Returns the number of times Cache lookup methods have returned an uncached (newly loaded) value, or null. Multiple concurrent calls to Cache lookup methods on an absent value can result in multiple misses, all returning the results of a single cache load operation.

Popular methods of CacheStats

  • hitCount
    Returns the number of times Cache lookup methods have returned a cached value.
  • evictionCount
    Returns the number of times an entry has been evicted. This count does not include manual Cache#inva
  • loadExceptionCount
    Returns the number of times Cache lookup methods threw an exception while loading a new value. This
  • totalLoadTime
    Returns the total number of nanoseconds the cache has spent loading new values. This can be used to
  • loadSuccessCount
    Returns the number of times Cache lookup methods have successfully loaded a new value. This is alway
  • requestCount
    Returns the number of times Cache lookup methods have returned either a cached or uncached value. Th
  • hitRate
    Returns the ratio of cache requests which were hits. This is defined as hitCount / requestCount, or
  • loadCount
    Returns the total number of times that Cache lookup methods attempted to load new values. This inclu
  • <init>
    Constructs a new CacheStats instance.Five parameters of the same type in a row is a bad thing, but t
  • missRate
    Returns the ratio of cache requests which were misses. This is defined as missCount / requestCount,
  • averageLoadPenalty
    Returns the average time spent loading new values. This is defined as totalLoadTime / (loadSuccessCo
  • loadExceptionRate
    Returns the ratio of cache loading attempts which threw exceptions. This is defined as loadException
  • averageLoadPenalty,
  • loadExceptionRate,
  • toString,
  • minus,
  • plus

Popular in Java

  • Making http requests using okhttp
  • setScale (BigDecimal)
  • runOnUiThread (Activity)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Path (java.nio.file)
  • IsNull (org.hamcrest.core)
    Is the value null?
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now