Class ExpiringMap.Expirer

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

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

      Constructors 
      Constructor Description
      Expirer()
      Creates a new instance of Expirer.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getExpirationInterval()
      Get the interval in which an object will live in the map before it is removed.
      int getTimeToLive()  
      boolean isRunning()
      Checks to see if the thread is running
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Expirer

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

      • run

        public void run()
        Specified by:
        run in interface java.lang.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