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 |
---|
PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy()
Default constructor.
|
PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy(long timeToLiveMillis)
Construct a policy with the given time-to-live constant measured in
milliseconds.
|
PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy(long timeToLive,
TimeUnit timeUnit)
Construct a policy with the given time-to-live constant measured in
the given time unit of measure.
|
public PassiveExpiringMap.ConstantTimeToLiveExpirationPolicy()
public PassiveExpiringMap.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 PassiveExpiringMap.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.IllegalArgumentException
- 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–2013 The Apache Software Foundation. All rights reserved.