@Test
  public void testSizeEvictionClearsIndex() throws Exception {
    when(mClock.now()).thenReturn(TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS));
    CacheKey key1 = putOneThingInCache();
    CacheKey key2 = new SimpleCacheKey("bar");
    CacheKey key3 = new SimpleCacheKey("duck");
    byte[] value2 = new byte[(int) FILE_CACHE_MAX_SIZE_HIGH_LIMIT];
    value2[80] = 'c';
    WriterCallback callback = WriterCallbacks.from(value2);
    when(mClock.now()).thenReturn(TimeUnit.MILLISECONDS.convert(2, TimeUnit.DAYS));
    mCache.insert(key2, callback);
    // now over limit. Next write will evict key1
    when(mClock.now()).thenReturn(TimeUnit.MILLISECONDS.convert(3, TimeUnit.DAYS));
    mCache.insert(key3, callback);
    assertFalse(mCache.hasKeySync(key1));
    assertFalse(mCache.hasKey(key1));
    assertTrue(mCache.hasKeySync(key3));
    assertTrue(mCache.hasKey(key3));
  }
Verify that multiple threads can write to the cache at the same time.
imagepipeline-base/src/test/java/com/facebook/cache/disk/DiskStorageCacheTest.java