HeapCache extends AbstractSearchableCache<K, V> { @Override public long size() { return caffeine.estimatedSize(); } 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 size() { cache.put("a", "a"); cache.put("b", "a"); cache.put("c", "a"); cache.put("c", "a"); assertEquals(cache.size(), 3); }