@Test
  public void testAccessCountUpdateInLFUGhostList() {
    // 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 LFU
    CloseableReference<Integer> originalRef1 = newReference(10);
    CloseableReference<Integer> valueRef1a = mCache.cache(KEYS[1], originalRef1);
    valueRef1a.close();

    // insert item2 to LFU
    CloseableReference<Integer> originalRef2 = newReference(20);
    CloseableReference<Integer> valueRef2a = mCache.cache(KEYS[2], originalRef2);
    originalRef2.close();
    valueRef2a.close();

    // insert item3 to LFU, this should evict item1 from LFU and insert it to the LFU ghost list
    CloseableReference<Integer> originalRef3 = newReference(30);
    CloseableReference<Integer> valueRef3a = mCache.cache(KEYS[3], originalRef3);
    originalRef3.close();
    valueRef3a.close();
    assertExclusivelyOwnedSize(2, 50);
    assertKeyIsInLFUGhostList(KEYS[1], 1);

    // try to access the evicted item: item1, and check its accessCount is updated correctly
    CloseableReference<Integer> valueRef1b = mCache.get(KEYS[1]);
    assertNull(valueRef1b);
    assertExclusivelyOwnedSize(2, 50);
    assertKeyIsInLFUGhostList(KEYS[1], 2);

    // validate item1's state is correct after inserting the element again to the cache.
    CloseableReference<Integer> valueRef1c = mCache.cache(KEYS[1], originalRef1);
    originalRef1.close();
    assertSharedWithAccessCount(KEYS[1], 10, 3);
    // also, make sure it was added to the MFU now.
    valueRef1c.close();
    assertMFUExclusivelyOwned(KEYS[1], 10);
  }
This test makes sure that the accessCount state is updated for keys in the ghost list. Test:
add item1 to the ghost list, and try to access this element (after it was evicted), and check
that the access number was updated in the ghost list.
imagepipeline-base/src/test/java/com/facebook/imagepipeline/cache/AbstractAdaptiveCountingMemoryCacheTest.java