@Test
  public void testAddKeyToMFHGhostList() {
    // Cache has 4 entries; 2 for LFU and 2 for MFU
    // key is considered as MFU, if its accessCount > 1
    mCache =
        createDummyAdaptiveCountingMemoryCache(
            mParamsSupplier,
            mCacheTrimStrategy,
            mValueDescriptor,
            100,
            1,
            2,
            initialLFUCacheFractionPromil);

    // insert item1 to MFU
    CloseableReference<Integer> originalRef1 = newReference(10);
    CloseableReference<Integer> valueRef1a = mCache.cache(KEYS[1], originalRef1);
    CloseableReference<Integer> valueRef1b = mCache.get(KEYS[1]);
    originalRef1.close();
    valueRef1a.close();
    valueRef1b.close();
    assertMFUExclusivelyOwned(KEYS[1], 10);

    // insert item2 to MFU
    CloseableReference<Integer> originalRef2 = newReference(20);
    CloseableReference<Integer> valueRef2a = mCache.cache(KEYS[2], originalRef2);
    CloseableReference<Integer> valueRef2b = mCache.get(KEYS[2]);
    originalRef2.close();
    valueRef2a.close();
    valueRef2b.close();
    assertMFUExclusivelyOwned(KEYS[1], 10);
    assertMFUExclusivelyOwned(KEYS[2], 20);

    // insert item3 to MFU, the cache should evict item1 and insert it to the MFU ghost list
    CloseableReference<Integer> originalRef3 = newReference(30);
    CloseableReference<Integer> valueRef3a = mCache.cache(KEYS[3], originalRef3);
    CloseableReference<Integer> valueRef3b = mCache.get(KEYS[3]);
    originalRef3.close();
    valueRef3a.close();
    valueRef3b.close();
    assertMFUExclusivelyOwned(KEYS[2], 20);
    assertMFUExclusivelyOwned(KEYS[3], 30);
    assertKeyIsInMFUGhostList(KEYS[1]);
  }
check if the MFU keys are inserted to the MFU ghost list after eviction.
imagepipeline-base/src/test/java/com/facebook/imagepipeline/cache/AbstractAdaptiveCountingMemoryCacheTest.java