CompositeDataStoreCache extends AbstractCache<String, File> implements Closeable { @Override public void invalidate(Object key) { stagingCache.invalidate((String) key); downloadCache.invalidate(key); } CompositeDataStoreCache(String path, File home, long size, int uploadSplitPercentage,
        int uploadThreads, CacheLoader<String, InputStream> loader, final StagingUploader uploader,
        StatisticsProvider statsProvider, ListeningExecutorService listeningExecutor,
        ScheduledExecutorService scheduledExecutor /* purge scheduled executor */,
        ExecutorService executor /* File cache executor */,
        int purgeInterval /* async purge interval secs */,
        int stagingRetryInterval /* async retry interval secs */); @Nullable File getIfPresent(String key); @Nullable @Override File getIfPresent(Object key); File get(String key); @Override void invalidate(Object key); boolean stage(String key, File file); DataStoreCacheStatsMBean getStagingCacheStats(); DataStoreCacheStatsMBean getCacheStats(); @Override void close();  }
@Test public void invalidate() throws Exception { LOG.info("Starting invalidate"); File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile()); loader.write(ID_PREFIX + 0, f); File cached = cache.get(ID_PREFIX + 0); assertNotNull(cached); assertTrue(Files.equal(f, cached)); cache.invalidate(ID_PREFIX + 0); cached = cache.getIfPresent(ID_PREFIX + 0); assertNull(cached); assertCacheStats(cache.getStagingCacheStats(), 0, 0, 0, 0); assertEquals(2, cache.getStagingCacheStats().getLoadCount()); assertEquals(0, cache.getStagingCacheStats().getLoadSuccessCount()); assertCacheStats(cache.getCacheStats(), 0, 0, 0, 2); assertEquals(1, cache.getCacheStats().getLoadCount()); assertEquals(1, cache.getCacheStats().getLoadSuccessCount()); assertEquals(0, cache.getCacheStats().getEvictionCount()); LOG.info("Finished invalidate"); }