Class ExpiringMap.Expirer

  • All Implemented Interfaces:
    Runnable
    Enclosing class:
    ExpiringMap<K,​V>

    public class ExpiringMap.Expirer
    extends Object
    implements Runnable
    A Thread that monitors an ExpiringMap and will remove elements that have passed the threshold.
    • Constructor Detail

      • Expirer

        public Expirer()
        Creates a new instance of Expirer.
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface Runnable
      • 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