Class ExpiringMap.Expirer
java.lang.Object
org.apache.mina.util.ExpiringMap.Expirer
- All Implemented Interfaces:
Runnable
- Enclosing class:
ExpiringMap<K,V>
A Thread that monitors an
ExpiringMap and will remove
elements that have passed the threshold.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate longprivate final Threadprivate booleanprivate final ReadWriteLockprivate long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet the interval in which an object will live in the map before it is removed.intbooleanChecks to see if the thread is runningprivate voidvoidrun()voidsetExpirationInterval(long expirationInterval) Set the interval in which an object will live in the map before it is removed.voidsetTimeToLive(long timeToLive) Update the value for the time-to-livevoidKick off this thread which will look for old objects and remove them.voidIf this thread has not started, then start it.voidStop the thread from monitoring the map.
-
Field Details
-
stateLock
-
timeToLiveMillis
private long timeToLiveMillis -
expirationIntervalMillis
private long expirationIntervalMillis -
running
private boolean running -
expirerThread
-
-
Constructor Details
-
Expirer
public Expirer()Creates a new instance of Expirer.
-
-
Method Details
-
run
-
processExpires
private void processExpires() -
startExpiring
public void startExpiring()Kick off this thread which will look for old objects and remove them. -
startExpiringIfNotStarted
public void startExpiringIfNotStarted()If this thread has not started, then start it. Otherwise just return; -
stopExpiring
public void stopExpiring()Stop the thread from monitoring the map. -
isRunning
public boolean isRunning()Checks to see if the thread is running- Returns:
- If the thread is running, true. Otherwise false.
-
getTimeToLive
public int getTimeToLive()- Returns:
- the Time-to-live value in seconds.
-
setTimeToLive
public void setTimeToLive(long timeToLive) Update the value for the time-to-live- Parameters:
timeToLive- The time-to-live (seconds)
-
getExpirationInterval
public int getExpirationInterval()Get the interval in which an object will live in the map before it is removed.- Returns:
- The time in seconds.
-
setExpirationInterval
public void setExpirationInterval(long expirationInterval) Set the interval in which an object will live in the map before it is removed.- Parameters:
expirationInterval- The time in seconds
-