K
- the type of the keys in the mapV
- the type of the values in the mappublic static class PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy<K,V> extends Object implements 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 timeUnit)
Construct a policy with the given time-to-live constant measured in
the given time unit of measure.
|
Modifier and Type | Method and Description |
---|---|
long |
expirationTime(K key,
V value)
Determine the expiration time for the given key-value entry.
|
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.Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.