@Test public void openWithInvalidFileSizeClearsDirectory() throws Exception { generateSomeGarbageFiles(); createJournal("CLEAN k1 0000x001"); mCache = new IgDiskCache(mCacheDir, Integer.MAX_VALUE); assertGarbageFilesAllDeleted(); assertThat(mCache.get("k1").isPresent()).isFalse(); }
public OptionalStream<SnapshotInputStream> get(String key) { validateKey(key); Entry entry; synchronized (mDiskCacheLock) { entry = mLruEntries.get(key); } if (entry == null || !entry.isReadable()) { mMissCount++; return OptionalStream.absent(); } else { mHitCount++; try { return OptionalStream.of(new SnapshotInputStream(entry)); } catch (IOException e) { return OptionalStream.absent(); } } }
IgDiskCache { public OptionalStream<SnapshotInputStream> get(String key) { validateKey(key); Entry entry; synchronized (mDiskCacheLock) { entry = mLruEntries.get(key); } if (entry == null || !entry.isReadable()) { mMissCount++; return OptionalStream.absent(); } else { mHitCount++; try { return OptionalStream.of(new SnapshotInputStream(entry)); } catch (IOException e) { return OptionalStream.absent(); } } } }
IgDiskCache { public OptionalStream<SnapshotInputStream> get(String key) { validateKey(key); Entry entry; synchronized (mDiskCacheLock) { entry = mLruEntries.get(key); } if (entry == null || !entry.isReadable()) { mMissCount++; return OptionalStream.absent(); } else { mHitCount++; try { return OptionalStream.of(new SnapshotInputStream(entry)); } catch (IOException e) { return OptionalStream.absent(); } } } 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); }
IgDiskCache { public OptionalStream<SnapshotInputStream> get(String key) { validateKey(key); Entry entry; synchronized (mDiskCacheLock) { entry = mLruEntries.get(key); } if (entry == null || !entry.isReadable()) { mMissCount++; return OptionalStream.absent(); } else { mHitCount++; try { return OptionalStream.of(new SnapshotInputStream(entry)); } catch (IOException e) { return OptionalStream.absent(); } } } 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(); }
IgDiskCache { public OptionalStream<SnapshotInputStream> get(String key) { validateKey(key); Entry entry; synchronized (mDiskCacheLock) { entry = mLruEntries.get(key); } if (entry == null || !entry.isReadable()) { mMissCount++; return OptionalStream.absent(); } else { mHitCount++; try { return OptionalStream.of(new SnapshotInputStream(entry)); } catch (IOException e) { return OptionalStream.absent(); } } } 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();  }