CacheChangesTracker implements Closeable { public boolean mightBeenAffected(String key) { return keyFilter.apply(key) && lazyBloomFilter.mightContain(key); } CacheChangesTracker(Predicate<String> keyFilter, List<CacheChangesTracker> changeTrackers, int bloomFilterSize); void putDocument(String key); void invalidateDocument(String key); boolean mightBeenAffected(String key); @Override void close();  }
@Test public void testGetLoaderAffectsTracker() throws ExecutionException { NodeDocumentCache cache = createCache(); Path parent = Path.fromString("/parent"); CacheChangesTracker tracker = cache.registerTracker(getKeyLowerLimit(parent), getKeyUpperLimit(parent)); assertFalse(tracker.mightBeenAffected("2:/parent/xyz")); cache.getIfPresent("2:/parent/xyz"); assertFalse(tracker.mightBeenAffected("2:/parent/xyz")); cache.get("2:/parent/xyz", new Callable<NodeDocument>() { @Override public NodeDocument call() throws Exception { return createDoc("2:/parent/xyz"); } }); assertTrue(tracker.mightBeenAffected("2:/parent/xyz")); }
@Test public void testOnlyExternalChanges() { NodeDocumentCache cache = createCache(); Path parent = Path.fromString("/parent"); CacheChangesTracker tracker = cache.registerTracker(getKeyLowerLimit(parent), getKeyUpperLimit(parent)); cache.putNonConflictingDocs(tracker, ImmutableSet.of(createDoc("2:/parent/local"))); assertFalse(tracker.mightBeenAffected("2:/parent/local")); cache.put(createDoc("2:/parent/external")); assertTrue(tracker.mightBeenAffected("2:/parent/external")); }