Class CachedResult<T>

java.lang.Object
net.solarnetwork.util.CachedResult<T>
Type Parameters:
T - The type of object that is cached.

public class CachedResult<T> extends Object
A cached object holder.
Version:
1.0
Author:
matt
  • Constructor Details

    • CachedResult

      public CachedResult(T result, long ttl, TimeUnit unit)
      Constructor. The current time will be used for the created property.
      Parameters:
      result - The result to cache.
      ttl - The time to live, after which the result should be considered expired.
      unit - The time unit for the expiration.
    • CachedResult

      public CachedResult(T result, long created, long ttl, TimeUnit unit)
      Constructor.
      Parameters:
      result - The result to cache.
      created - The creation time to use for the result.
      ttl - The time to live, after which the result should be considered expired.
      unit - The time unit for the expiration.
  • Method Details

    • isValid

      public boolean isValid()
      Test if this result has not expired.
      Returns:
      true if the result has not expired.
    • getCreated

      public long getCreated()
      Get the system time this object was created.
      Returns:
      The system time this object was created.
    • getExpires

      public long getExpires()
      Get the system time this object expires at.
      Returns:
      The system time this object expires at.
    • getResult

      public T getResult()
      Get the cached result object.
      Returns:
      The result object.