IgDiskCache { public void remove(String key) throws IllegalStateException { validateKey(key); Entry entry; synchronized (mDiskCacheLock) { entry = mLruEntries.remove(key); } if (entry != null) { if (entry.getCurrentEditorStream() != null) { throw new IllegalStateException( "trying to remove a disk cache entry that is still under edit."); } File file = entry.getCleanFile(); if (!file.exists() || file.delete()) { mSizeInBytes.getAndAdd(-entry.getLengthInBytes()); } else { synchronized (mRemoveRetryLock) { mRemoveRetryList.add(entry); } } } } IgDiskCache(File directory);  IgDiskCache(File directory, Executor serialExecutor);  IgDiskCache(File directory, long maxSizeInBytes);  IgDiskCache(File directory, long maxSizeInBytes, Executor serialExecutor);  IgDiskCache(File directory, long maxSizeInBytes, int maxCount);  IgDiskCache(File directory, long maxSizeInBytes, int maxCount, Executor serialExecutor); boolean has(String key); OptionalStream<SnapshotInputStream> get(String key); OptionalStream<EditorOutputStream> edit(String key); void remove(String key); void flush(); void close(); File getDirectory(); long getMaxSizeInBytes(); int getMaxCount(); void setMaxSizeInBytes(long maxSizeInBytes); long size(); int count(); final String getHitRateString();  }
@Test public void removeAbsentElement() throws Exception { mCache.remove("a"); }
@Test public void removeHandlesMissingFile() throws Exception { set(mCache, "a", "a"); getCleanFile("a").delete(); mCache.remove("a"); }
@Test public void explicitRemoveAppliedToDiskImmediately() throws Exception { set(mCache, "k1", "ABC"); File k1 = getCleanFile("k1"); assertThat(readFile(k1)).isEqualTo("ABC"); mCache.remove("k1"); assertThat(k1.exists()).isFalse(); }