public class ExpiringMap.Expirer
extends java.lang.Object
implements java.lang.Runnable
ExpiringMap and will remove
elements that have passed the threshold.| Modifier and Type | Field and Description |
|---|---|
private long |
expirationIntervalMillis |
private java.lang.Thread |
expirerThread |
private boolean |
running |
private java.util.concurrent.locks.ReadWriteLock |
stateLock |
private long |
timeToLiveMillis |
| Constructor and Description |
|---|
Expirer()
Creates a new instance of Expirer.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getExpirationInterval()
Get the interval in which an object will live in the map before
it is removed.
|
int |
getTimeToLive()
Returns the Time-to-live value.
|
boolean |
isRunning()
Checks to see if the thread is running
|
private void |
processExpires() |
void |
run() |
void |
setExpirationInterval(long expirationInterval)
Set the interval in which an object will live in the map before
it is removed.
|
void |
setTimeToLive(long timeToLive)
Update the value for the time-to-live
|
void |
startExpiring()
Kick off this thread which will look for old objects and remove them.
|
void |
startExpiringIfNotStarted()
If this thread has not started, then start it.
|
void |
stopExpiring()
Stop the thread from monitoring the map.
|
private final java.util.concurrent.locks.ReadWriteLock stateLock
private long timeToLiveMillis
private long expirationIntervalMillis
private boolean running
private final java.lang.Thread expirerThread
public void run()
run in interface java.lang.Runnableprivate void processExpires()
public void startExpiring()
public void startExpiringIfNotStarted()
public void stopExpiring()
public boolean isRunning()
public int getTimeToLive()
public void setTimeToLive(long timeToLive)
timeToLive - The time-to-live (seconds)public int getExpirationInterval()
public void setExpirationInterval(long expirationInterval)
expirationInterval - The time in seconds