Interface TimeReference

  • public interface TimeReference
    Time reference for a cache. By default the current time is retrieved with System.currentTimeMillis(). Another time reference can be specified if the application uses a different time source or when a simulated clock should be used.

    An instance may implement AutoCloseable if resources need to be cleaned up.

    Jens Wilke
    • Method Detail

      • sleep

        void sleep​(long millis)
            throws InterruptedException
        Wait for the specified amount of time in milliseconds.

        The value of 0 means that the thread should pause and other processing should be done. In a simulated clock this would wait for concurrent processing and, if no processing is happening, advance the time to the next event.

      • toMillis

        default long toMillis​(long millis)
        Convert a value returned by millis() to milliseconds since epoch. This can be overridden in case another time scale and or reference is used. Conversion is needed for correctly scheduling timer task that regularly process the expiry tasks.