@Override public void putAll(Map<? extends K, ? extends V> map) { Assert.notNull(map, "map"); long expiration = expirationNanos.get(); ExpirationPolicy expirationPolicy = this.expirationPolicy.get(); writeLock.lock(); try { for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) putInternal(entry.getKey(), entry.getValue(), expirationPolicy, expiration); } finally { writeLock.unlock(); } }
@Override public void putAll(Map<? extends K, ? extends V> map) { Assert.notNull(map, "map"); long expiration = expirationNanos.get(); ExpirationPolicy expirationPolicy = this.expirationPolicy.get(); writeLock.lock(); try { for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) putInternal(entry.getKey(), entry.getValue(), expirationPolicy, expiration); } finally { writeLock.unlock(); } }
/** * Puts {@code value} in the map for {@code key}. Resets the entry's expiration unless an entry already exists for the * same {@code key} and {@code value}. * * @param key to put value for * @param value to put for key * @return the old value * @throws NullPointerException if {@code key} is null */ @Override public V put(K key, V value) { Assert.notNull(key, "key"); return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); }
@Override public void putAll(Map<? extends K, ? extends V> map) { Assert.notNull(map, "map"); long expiration = expirationNanos.get(); ExpirationPolicy expirationPolicy = this.expirationPolicy.get(); writeLock.lock(); try { for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) putInternal(entry.getKey(), entry.getValue(), expirationPolicy, expiration); } finally { writeLock.unlock(); } }
/** * Puts {@code value} in the map for {@code key}. Resets the entry's expiration unless an entry already exists for the * same {@code key} and {@code value}. * * @param key to put value for * @param value to put for key * @return the old value * @throws NullPointerException if {@code key} is null */ @Override public V put(K key, V value) { Assert.notNull(key, "key"); return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); }
/** * Puts {@code value} in the map for {@code key}. Resets the entry's expiration unless an entry already exists for the * same {@code key} and {@code value}. * * @param key to put value for * @param value to put for key * @return the old value * @throws NullPointerException if {@code key} is null */ @Override public V put(K key, V value) { Assert.notNull(key, "key"); return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); }
@Override public V replace(K key, V value) { Assert.notNull(key, "key"); writeLock.lock(); try { if (entries.containsKey(key)) { return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); } else return null; } finally { writeLock.unlock(); } }
@Override public V replace(K key, V value) { Assert.notNull(key, "key"); writeLock.lock(); try { if (entries.containsKey(key)) { return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); } else return null; } finally { writeLock.unlock(); } }
@Override public V replace(K key, V value) { Assert.notNull(key, "key"); writeLock.lock(); try { if (entries.containsKey(key)) { return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); } else return null; } finally { writeLock.unlock(); } }
@Override public boolean replace(K key, V oldValue, V newValue) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null && entry.getValue().equals(oldValue)) { putInternal(key, newValue, expirationPolicy.get(), expirationNanos.get()); return true; } else return false; } finally { writeLock.unlock(); } }
@Override public boolean replace(K key, V oldValue, V newValue) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null && entry.getValue().equals(oldValue)) { putInternal(key, newValue, expirationPolicy.get(), expirationNanos.get()); return true; } else return false; } finally { writeLock.unlock(); } }
@Override public boolean replace(K key, V oldValue, V newValue) { Assert.notNull(key, "key"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null && entry.getValue().equals(oldValue)) { putInternal(key, newValue, expirationPolicy.get(), expirationNanos.get()); return true; } else return false; } finally { writeLock.unlock(); } }
@Override public V putIfAbsent(K key, V value) { Assert.notNull(key, "key"); writeLock.lock(); try { if (!entries.containsKey(key)) return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); else return entries.get(key).getValue(); } finally { writeLock.unlock(); } }
@Override public V putIfAbsent(K key, V value) { Assert.notNull(key, "key"); writeLock.lock(); try { if (!entries.containsKey(key)) return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); else return entries.get(key).getValue(); } finally { writeLock.unlock(); } }
@Override public V putIfAbsent(K key, V value) { Assert.notNull(key, "key"); writeLock.lock(); try { if (!entries.containsKey(key)) return putInternal(key, value, expirationPolicy.get(), expirationNanos.get()); else return entries.get(key).getValue(); } finally { writeLock.unlock(); } }
/** * Puts {@code value} in the map for {@code key}. Resets the entry's expiration unless an entry already exists for the * same {@code key} and {@code value}. Requires that variable expiration be enabled. * * @param key Key to put value for * @param value Value to put for key * @param duration the length of time after an entry is created that it should be removed * @param timeUnit the unit that {@code duration} is expressed in * @return the old value * @throws UnsupportedOperationException If variable expiration is not enabled * @throws NullPointerException if {@code key}, {@code expirationPolicy} or {@code timeUnit} are null */ public V put(K key, V value, ExpirationPolicy expirationPolicy, long duration, TimeUnit timeUnit) { Assert.notNull(key, "key"); Assert.notNull(expirationPolicy, "expirationPolicy"); Assert.notNull(timeUnit, "timeUnit"); Assert.operation(variableExpiration, "Variable expiration is not enabled"); return putInternal(key, value, expirationPolicy, TimeUnit.NANOSECONDS.convert(duration, timeUnit)); }
/** * Puts {@code value} in the map for {@code key}. Resets the entry's expiration unless an entry already exists for the * same {@code key} and {@code value}. Requires that variable expiration be enabled. * * @param key Key to put value for * @param value Value to put for key * @param duration the length of time after an entry is created that it should be removed * @param timeUnit the unit that {@code duration} is expressed in * @return the old value * @throws UnsupportedOperationException If variable expiration is not enabled * @throws NullPointerException if {@code key}, {@code expirationPolicy} or {@code timeUnit} are null */ public V put(K key, V value, ExpirationPolicy expirationPolicy, long duration, TimeUnit timeUnit) { Assert.notNull(key, "key"); Assert.notNull(expirationPolicy, "expirationPolicy"); Assert.notNull(timeUnit, "timeUnit"); Assert.operation(variableExpiration, "Variable expiration is not enabled"); return putInternal(key, value, expirationPolicy, TimeUnit.NANOSECONDS.convert(duration, timeUnit)); }
/** * Puts {@code value} in the map for {@code key}. Resets the entry's expiration unless an entry already exists for the * same {@code key} and {@code value}. Requires that variable expiration be enabled. * * @param key Key to put value for * @param value Value to put for key * @param duration the length of time after an entry is created that it should be removed * @param timeUnit the unit that {@code duration} is expressed in * @return the old value * @throws UnsupportedOperationException If variable expiration is not enabled * @throws NullPointerException if {@code key}, {@code expirationPolicy} or {@code timeUnit} are null */ public V put(K key, V value, ExpirationPolicy expirationPolicy, long duration, TimeUnit timeUnit) { Assert.notNull(key, "key"); Assert.notNull(expirationPolicy, "expirationPolicy"); Assert.notNull(timeUnit, "timeUnit"); Assert.operation(variableExpiration, "Variable expiration is not enabled"); return putInternal(key, value, expirationPolicy, TimeUnit.NANOSECONDS.convert(duration, timeUnit)); }