Class CachedObject<V>

java.lang.Object
com.nimbusds.jose.util.cache.CachedObject<V>
Type Parameters:
V - The object type.

@Immutable public final class CachedObject<V> extends Object
Cached object.
Version:
2024-04-20
  • Constructor Details

    • CachedObject

      public CachedObject(V object, long timestamp, long expirationTime)
      Creates a new cached object.
      Parameters:
      object - The cached object. Must not be null.
      timestamp - The caching timestamp, in milliseconds since the Unix epoch.
      expirationTime - The expiration time, in milliseconds since the Unix epoch.
  • Method Details

    • computeExpirationTime

      public static long computeExpirationTime(long currentTime, long timeToLive)
      Computes expiration time.
      Parameters:
      currentTime - The current time, in milliseconds since the Unix epoch.
      timeToLive - The time to live, in milliseconds.
      Returns:
      The expiration time, in milliseconds since the Unix epoch.
    • get

      public V get()
      Returns the cached object.
      Returns:
      The cached object.
    • getTimestamp

      public long getTimestamp()
      Returns the caching timestamp.
      Returns:
      The caching timestamp, in milliseconds since the Unix epoch.
    • getExpirationTime

      public long getExpirationTime()
      Returns the expiration time.
      Returns:
      The expiration time, in milliseconds since the Unix epoch.
    • isValid

      public boolean isValid(long currentTime)
      Returns true if the cached object is valid.
      Parameters:
      currentTime - The current time, in milliseconds since the Unix epoch.
      Returns:
      true if the cached object is valid, else false.
    • isExpired

      public boolean isExpired(long currentTime)
      Returns true if the cached object expired.
      Parameters:
      currentTime - The current time, in milliseconds since the Unix epoch.
      Returns:
      true if the cached object expired, else false.