Class CmsExpiringValue<T>

  • Type Parameters:
    T - the type of the cached value

    public class CmsExpiringValue<T>
    extends java.lang.Object
    Simple utility class for caching a single value with a given cache expiration time.

    If the time between the last write operation and a read operation is longer than the expiration time, null will be returned from the read operation.

    • Constructor Summary

      Constructors 
      Constructor Description
      CmsExpiringValue​(long expirationTime)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get()
      Gets the cached value.
      void set​(T value)
      Sets the cached value.
      • Methods inherited from class java.lang.Object

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

      • CmsExpiringValue

        public CmsExpiringValue​(long expirationTime)
        Creates a new instance.

        Parameters:
        expirationTime - the expiration time in milliseconds
    • Method Detail

      • get

        public T get()
        Gets the cached value.

        Returns null if the last update was longer ago than the expiration time.

        Returns:
        the cached value
      • set

        public void set​(T value)
        Sets the cached value.

        Parameters:
        value - the cached value