Class CmsExpiringValue<T>

java.lang.Object
org.opencms.util.CmsExpiringValue<T>
Type Parameters:
T - the type of the cached value

public class CmsExpiringValue<T> extends 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 Details

    • CmsExpiringValue

      public CmsExpiringValue(long expirationTime)
      Creates a new instance.

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

    • 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