/** * Resets expiration for the entry corresponding to {@code key}. * * @param key to reset expiration for * @throws NullPointerException if {@code key} is null */ public void resetExpiration(K key) { Assert.notNull(key, "key"); ExpiringEntry<K, V> entry = getEntry(key); if (entry != null) resetEntry(entry, false); }
/** * Resets expiration for the entry corresponding to {@code key}. * * @param key to reset expiration for * @throws NullPointerException if {@code key} is null */ public void resetExpiration(K key) { Assert.notNull(key, "key"); ExpiringEntry<K, V> entry = getEntry(key); if (entry != null) resetEntry(entry, false); }
/** * Resets expiration for the entry corresponding to {@code key}. * * @param key to reset expiration for * @throws NullPointerException if {@code key} is null */ public void resetExpiration(K key) { Assert.notNull(key, "key"); ExpiringEntry<K, V> entry = getEntry(key); if (entry != null) resetEntry(entry, false); }
@Override @SuppressWarnings("unchecked") public V get(Object key) { ExpiringEntry<K, V> entry = getEntry(key); if (entry == null) { return load((K) key); } else if (ExpirationPolicy.ACCESSED.equals(entry.expirationPolicy.get())) resetEntry(entry, false); return entry.getValue(); }
/** * Sets the expiration duration for the entry corresponding to the given key. Supported only if variable expiration is * enabled. * * @param key Key to set expiration for * @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 * @throws NullPointerException if {@code key} or {@code timeUnit} are null * @throws UnsupportedOperationException If variable expiration is not enabled */ public void setExpiration(K key, long duration, TimeUnit timeUnit) { Assert.notNull(key, "key"); Assert.notNull(timeUnit, "timeUnit"); Assert.operation(variableExpiration, "Variable expiration is not enabled"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null) { entry.expirationNanos.set(TimeUnit.NANOSECONDS.convert(duration, timeUnit)); resetEntry(entry, true); } } finally { writeLock.unlock(); } }
/** * Sets the expiration duration for the entry corresponding to the given key. Supported only if variable expiration is * enabled. * * @param key Key to set expiration for * @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 * @throws NullPointerException if {@code key} or {@code timeUnit} are null * @throws UnsupportedOperationException If variable expiration is not enabled */ public void setExpiration(K key, long duration, TimeUnit timeUnit) { Assert.notNull(key, "key"); Assert.notNull(timeUnit, "timeUnit"); Assert.operation(variableExpiration, "Variable expiration is not enabled"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null) { entry.expirationNanos.set(TimeUnit.NANOSECONDS.convert(duration, timeUnit)); resetEntry(entry, true); } } finally { writeLock.unlock(); } }
@Override @SuppressWarnings("unchecked") public V get(Object key) { ExpiringEntry<K, V> entry = getEntry(key); if (entry == null) { return load((K) key); } else if (ExpirationPolicy.ACCESSED.equals(entry.expirationPolicy.get())) resetEntry(entry, false); return entry.getValue(); }
@Override @SuppressWarnings("unchecked") public V get(Object key) { ExpiringEntry<K, V> entry = getEntry(key); if (entry == null) { return load((K) key); } else if (ExpirationPolicy.ACCESSED.equals(entry.expirationPolicy.get())) resetEntry(entry, false); return entry.getValue(); }
/** * Sets the expiration duration for the entry corresponding to the given key. Supported only if variable expiration is * enabled. * * @param key Key to set expiration for * @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 * @throws NullPointerException if {@code key} or {@code timeUnit} are null * @throws UnsupportedOperationException If variable expiration is not enabled */ public void setExpiration(K key, long duration, TimeUnit timeUnit) { Assert.notNull(key, "key"); Assert.notNull(timeUnit, "timeUnit"); Assert.operation(variableExpiration, "Variable expiration is not enabled"); writeLock.lock(); try { ExpiringEntry<K, V> entry = entries.get(key); if (entry != null) { entry.expirationNanos.set(TimeUnit.NANOSECONDS.convert(duration, timeUnit)); resetEntry(entry, true); } } finally { writeLock.unlock(); } }
resetEntry(entry, false);
resetEntry(entry, false);
resetEntry(entry, false);