public boolean putIfAbsent(final K key, final V value, long ttl) { long latency = System.nanoTime(); Holder<K, V> h = new Holder<K, V>(key, value, findTimingsHolder(ttl)); if (map.putIfAbsent(key, h) == null) { updateTimingCache(h); try { onAddItem(key, value); } finally { latency = System.nanoTime() - latency; statistics.putCount.incrementAndGet(); statistics.putLatency.addAndGet(latency); updateSizeMetric(); } return true; } return false; }
public boolean putIfAbsent(final K key, final V value, long ttl) { long latency = System.nanoTime(); Holder<K, V> h = new Holder<K, V>(key, value, findTimingsHolder(ttl)); if (map.putIfAbsent(key, h) == null) { updateTimingCache(h); try { onAddItem(key, value); } finally { latency = System.nanoTime() - latency; statistics.putCount.incrementAndGet(); statistics.putLatency.addAndGet(latency); updateSizeMetric(); } return true; } return false; }
public void put(final K key, final V value, long ttl) { long latency = System.nanoTime(); try { Holder<K, V> h = new Holder<K, V>(key, value, findTimingsHolder(ttl)); Holder<K, V> old = map.put(key, h); onAddItem(key, value); updateTimingCache(h); if (old != null) { long removeLatency = System.nanoTime(); try { onRemoveItem(old, false); } finally { removeLatency = System.nanoTime() - removeLatency; statistics.removeCount.incrementAndGet(); statistics.removeLatency.addAndGet(removeLatency); } } } finally { latency = System.nanoTime() - latency; statistics.putCount.incrementAndGet(); statistics.putLatency.addAndGet(latency); updateSizeMetric(); } }
public void put(final K key, final V value, long ttl) { long latency = System.nanoTime(); try { Holder<K, V> h = new Holder<K, V>(key, value, findTimingsHolder(ttl)); Holder<K, V> old = map.put(key, h); onAddItem(key, value); updateTimingCache(h); if (old != null) { long removeLatency = System.nanoTime(); try { onRemoveItem(old, false); } finally { removeLatency = System.nanoTime() - removeLatency; statistics.removeCount.incrementAndGet(); statistics.removeLatency.addAndGet(removeLatency); } } } finally { latency = System.nanoTime() - latency; statistics.putCount.incrementAndGet(); statistics.putLatency.addAndGet(latency); updateSizeMetric(); } }
f.setRemoved(); } else { updateTimingCache(f); onAddItem(f.getKey(), f.get()); if (outdated != null) updateTimingCache(f);
f.setRemoved(); } else { updateTimingCache(f); onAddItem(f.getKey(), f.get()); if (outdated != null) updateTimingCache(f);