K - the type of the keys in the map
V - the type of the values in the map
public static class PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<K,V> extends Objectimplements PassiveExpiringMap .ExpirationPolicy <K ,V>
ExpirationPolicy that returns a expiration time that is a constant about of time in the future from the current time.
| Constructor and Description |
|---|
ConstantTimeToLiveExpirationPolicy()
Default constructor.
|
ConstantTimeToLiveExpirationPolicy(long timeToLiveMillis)
Construct a policy with the given time-to-live constant measured in milliseconds.
|
ConstantTimeToLiveExpirationPolicy(long timeToLive, TimeUnit
Construct a policy with the given time-to-live constant measured in the given time unit of measure.
|
public ConstantTimeToLiveExpirationPolicy()
public ConstantTimeToLiveExpirationPolicy(long timeToLiveMillis)
timeToLiveMillis - the constant amount of time (in milliseconds) an entry is available before it expires. A negative value results in entries that NEVER expire. A zero value results in entries that ALWAYS expire.
public ConstantTimeToLiveExpirationPolicy(long timeToLive,
TimeUnit timeUnit)
timeToLive - the constant amount of time an entry is available before it expires. A negative value results in entries that NEVER expire. A zero value results in entries that ALWAYS expire.
timeUnit - the unit of time for the
timeToLive parameter, must not be null.
NullPointerException - if the time unit is null.
public long expirationTime(K key, V value)
expirationTime in interface
PassiveExpiringMap.ExpirationPolicy <K,V>
key - the key for the entry (ignored).
value - the value for the entry (ignored).
timeToLiveMillis ≥ 0, an expiration time of
timeToLiveMillis +
System.currentTimeMillis() is returned. Otherwise, -1 is returned indicating the entry never expires.