@Test public void load_and_refresh() { GuavaGraphCache<String, String> cache = newRefreshingCache(); String docId = randomUUID().toString(); ObjectVersionGraph<String> versionGraph = cache.load(docId); assertThat(versionGraph.isEmpty()).isTrue(); ObjectVersion<String> version = ObjectVersion.<String>builder() .changeset(ImmutableMap.of(ROOT.property("property"), "value")) .build(); documentStore.append(docId, ObjectVersionGraph.init(version).getTip()); documentStore.publish(); versionGraph = cache.load(docId); assertThat(versionGraph.isEmpty()).isFalse(); assertThat(versionGraph.getTip().getVersion()).isEqualTo(version); version = ObjectVersion.<String>builder() .changeset(ImmutableMap.of(ROOT.property("property"), "value2")) .build(); documentStore.append(docId, ObjectVersionGraph.init(version).getTip()); documentStore.publish(); versionGraph = cache.load(docId); assertThat(versionGraph.getTip().getVersion()).isEqualTo(version); cache = newRefreshingCache(); versionGraph = cache.load(docId); assertThat(versionGraph.getTip().getVersion()).isEqualTo(version); assertThat(cache.load(docId)).isSameAs(versionGraph); }
@Override public ObjectVersionGraph<M> load(Id docId) { try { return cache.get(docId); } catch (ExecutionException e) { throw new RuntimeException(e); } }
GuavaGraphCache implements GraphCache<Id, M> { @Override public ObjectVersionGraph<M> load(Id docId) { try { return cache.get(docId); } catch (ExecutionException e) { throw new RuntimeException(e); } } }
GuavaGraphCache implements GraphCache<Id, M> { @Override public ObjectVersionGraph<M> load(Id docId) { try { return cache.get(docId); } catch (ExecutionException e) { throw new RuntimeException(e); } } 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 ObjectVersionGraph<M> load(Id docId) { try { return cache.get(docId); } catch (ExecutionException e) { throw new RuntimeException(e); } } 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 ObjectVersionGraph<M> load(Id docId) { try { return cache.get(docId); } catch (ExecutionException e) { throw new RuntimeException(e); } } 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();  }