@Test public void testExpiryByTime() throws InterruptedException { Map<String, String> backing = new HashMap<>(); backing.put("foo", "1"); Lookup<String> delegate = new MapLookup<>(backing); CacheConfig config = new CacheConfig(1, 10); CachingLookup<String> lookup = new CachingLookup<>(delegate, config); Assert.assertEquals("1", lookup.lookup("foo")); backing.put("foo", "2"); Assert.assertEquals("1", lookup.lookup("foo")); Thread.sleep(1100); Assert.assertEquals("2", lookup.lookup("foo")); }
@Override public T lookup(String key) { return cache.getUnchecked(key); }
CachingLookup implements Lookup<T> { @Override public T lookup(String key) { return cache.getUnchecked(key); } }
CachingLookup implements Lookup<T> { @Override public T lookup(String key) { return cache.getUnchecked(key); } CachingLookup(final Lookup<T> delegate, CacheConfig cacheConfig); }
CachingLookup implements Lookup<T> { @Override public T lookup(String key) { return cache.getUnchecked(key); } CachingLookup(final Lookup<T> delegate, CacheConfig cacheConfig); @Override T lookup(String key); @Override Map<String, T> lookup(String... keys); @Override Map<String, T> lookup(Set<String> keys); }
CachingLookup implements Lookup<T> { @Override public T lookup(String key) { return cache.getUnchecked(key); } CachingLookup(final Lookup<T> delegate, CacheConfig cacheConfig); @Override T lookup(String key); @Override Map<String, T> lookup(String... keys); @Override Map<String, T> lookup(Set<String> keys);  }