private void putToOutdated(Holder<K, V> h) { if (outdated != null) outdated.put(h.k, h.v); }
private void putToOutdated(Holder<K, V> h) { if (outdated != null) outdated.put(h.k, h.v); }
public void put(final K key, final V value) { put(key, value, ttl); }
public <T> void register(Class<T> clazz, Dependency<T> dependency) { dependencies.put(clazz, dependency); }
public void setTTL(long ttl) { cache.put(id, this, ttl); }
public void put(final K key, final V value) { put(key, value, ttl); }
public <T> void register(Class<T> clazz, T dependency) { dependencies.put(clazz, new SingletonDependency<>(dependency)); }
dependencies.put(ob.getClass(), list);
@Test public void testCustomTTL() throws InterruptedException { Cache<String, String> cache = new Cache<String, String>(1, new Computable<String, String>() { @Override public String compute(String s) { return s.toUpperCase(); } }); cache.get("foo"); String bar = "BAR"; cache.put("bar", bar, 500); Assert.assertTrue(bar == cache.get("bar")); Thread.sleep(550); Assert.assertTrue(bar != cache.get("bar")); }
long compute = statistics.computeLatency.get(); long remove = statistics.removeLatency.get(); cache.put("foo", "bar"); Assert.assertEquals(1, statistics.getSize()); Assert.assertEquals(1, statistics.getGetCount());