HeapCache extends AbstractSearchableCache<K, V> { @Override public V get(final K key) { V value = caffeine.getIfPresent(key); if (value != null) { stats.incrementHitCount(); return value; } stats.incrementMissCount(); if (cacheLoader != null) { value = cacheLoader.load(key); if (value != null) { this.put(key, value); stats.incrementLoadCount(); return value; } } return null; } HeapCache(final String name, final CacheLoader<K, V> cacheLoader,
      final EvictionListener<K, V> evictionListener, final IndexHandler<K, V> indexHandler,
      final long limit, final TimeUnit expiryUnit, final long expiry); @Override void put(final K key, final V value); @Override void put(final K key, final V value, final TimeUnit timeUnit, final long duration); @Override V get(final K key); @Override V invalidate(final K key); @Override boolean contains(final K key); @Override void clear(); @Override long size(); @Override CacheStats stats();  }
@Test public void getLoadsData() { doReturn("d").when(cacheLoader).load("c"); assertEquals(cache.get("c"), "d"); verify(indexHandler).add("c", "d"); }