@Test public void auto_refresh_only_cached_graphs() { final MutableBoolean cacheRefreshed = new MutableBoolean(false); DocumentVersionStoreJdbc<String, String, JDocumentVersion<String>> proxyStore = new DocumentVersionStoreJdbc<String, String, JDocumentVersion<String>>(documentStore.options) { @Override protected FetchResults<String, String> doFetch(String docId, boolean optimized) { cacheRefreshed.setTrue(); throw new RuntimeException("Should not refresh!"); } }; String docId = randomUUID().toString(); GuavaGraphCache<String, String> cache = new GuavaGraphCache<String, String>(proxyStore, CacheBuilder.<String, ObjectVersionGraph<String>>newBuilder() .maximumSize(8)); ObjectVersion<String> version = ObjectVersion.<String>builder() .changeset(ImmutableMap.of(ROOT.property("property"), "value")) .build(); proxyStore.append(docId, ObjectVersionGraph.init(version).getTip()); cache.refresh(docId); assertThat(cacheRefreshed.getValue()).isFalse(); }
@Override public void refresh(Id docId) { if (cachedDocIds.contains(docId)) { cache.refresh(docId); } }
GuavaGraphCache implements GraphCache<Id, M> { @Override public void refresh(Id docId) { if (cachedDocIds.contains(docId)) { cache.refresh(docId); } } }
GuavaGraphCache implements GraphCache<Id, M> { @Override public void refresh(Id docId) { if (cachedDocIds.contains(docId)) { cache.refresh(docId); } } GuavaGraphCache(VersionStore<Id, M> versionStore,
                           CacheBuilder<Object, Object> cacheBuilder); @SuppressWarnings("unchecked")  GuavaGraphCache(VersionStore<Id, M> versionStore,
                           CacheBuilder<Object, Object> cacheBuilder,
                           GraphOptions<Id, M> graphOptions); }
GuavaGraphCache implements GraphCache<Id, M> { @Override public void refresh(Id docId) { if (cachedDocIds.contains(docId)) { cache.refresh(docId); } } GuavaGraphCache(VersionStore<Id, M> versionStore,
                           CacheBuilder<Object, Object> cacheBuilder); @SuppressWarnings("unchecked")  GuavaGraphCache(VersionStore<Id, M> versionStore,
                           CacheBuilder<Object, Object> cacheBuilder,
                           GraphOptions<Id, M> graphOptions); static Function<VersionStore<Id, M>, GraphCache<Id, M>> guavaCacheBuilder(CacheBuilder<Object, Object> cacheBuilder); static Function<VersionStore<Id, M>, GraphCache<Id, M>> guavaCacheBuilder(CacheBuilder<Object, Object> cacheBuilder,
                                                                                             GraphOptions<Id, M> graphOptions); @Override ObjectVersionGraph<M> load(Id docId); @Override void refresh(Id docId); @Override void evict(Id docId); @Override void evict(Iterator<Id> docIds); @Override void evictAll(); }
GuavaGraphCache implements GraphCache<Id, M> { @Override public void refresh(Id docId) { if (cachedDocIds.contains(docId)) { cache.refresh(docId); } } GuavaGraphCache(VersionStore<Id, M> versionStore,
                           CacheBuilder<Object, Object> cacheBuilder); @SuppressWarnings("unchecked")  GuavaGraphCache(VersionStore<Id, M> versionStore,
                           CacheBuilder<Object, Object> cacheBuilder,
                           GraphOptions<Id, M> graphOptions); static Function<VersionStore<Id, M>, GraphCache<Id, M>> guavaCacheBuilder(CacheBuilder<Object, Object> cacheBuilder); static Function<VersionStore<Id, M>, GraphCache<Id, M>> guavaCacheBuilder(CacheBuilder<Object, Object> cacheBuilder,
                                                                                             GraphOptions<Id, M> graphOptions); @Override ObjectVersionGraph<M> load(Id docId); @Override void refresh(Id docId); @Override void evict(Id docId); @Override void evict(Iterator<Id> docIds); @Override void evictAll();  }