public class TimeSpreadExpiration<T extends Poolable> extends Object implements Expiration<T>
This is the standard time based Expiration. It will invalidate
objects based on about how long ago they were allocated.
| Constructor and Description |
|---|
TimeSpreadExpiration(long lowerBound,
long upperBound,
TimeUnit unit)
Construct a new Expiration that will invalidate objects that are older
than the given lower bound, before they get older than the upper bound,
in the given time unit.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasExpired(SlotInfo<? extends T> info)
|
String |
toString()
Produces a String representation of this TimeSpreadExpiration.
|
public TimeSpreadExpiration(long lowerBound,
long upperBound,
TimeUnit unit)
Construct a new Expiration that will invalidate objects that are older than the given lower bound, before they get older than the upper bound, in the given time unit.
If the lowerBound is less than 1, the upperBound is less than the
lowerBound, or the unit is null, then an
IllegalArgumentException will be thrown.
lowerBound - Poolables younger than this, in the given unit, are not
considered expired. This value must be at least 1.upperBound - Poolables older than this, in the given unit, are always
considered expired. This value must be greater than the
lowerBound.unit - The TimeUnit of the bounds values. Never null.public boolean hasExpired(SlotInfo<? extends T> info)
Returns true, with uniformly increasing probability, if the
Poolable represented by the given SlotInfo is
older than the lower bound, eventually returning true with
100% certainty when the age of the Poolable is equal to or greater than
the upper bound.
The uniformity of the random expiration holds regardless of how often a Poolable is checked. That is to say, checking a Poolable more times within an interval of time, does not increase its chances of being declared expired.
hasExpired in interface Expiration<T extends Poolable>info - An informative representative of the slot being tested.
Never null.true if the Slot and Poolable in question should be
deallocated, false if it is valid and eligible for claiming.Copyright © 2011-2014–2015. All rights reserved.