Package com.nimbusds.jose.util.cache
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:
- 2023-02-15
-
-
Constructor Summary
Constructors Constructor Description CachedObject(V object, long timestamp, long expirationTime)Creates a new cached object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longcomputeExpirationTime(long currentTime, long timeToLive)Computes expiration time.Vget()Returns the cached object.longgetExpirationTime()Returns the expiration time.longgetTimestamp()Returns the caching timestamp.booleanisExpired(long currentTime)Returnstrueif the cached object expired.booleanisValid(long currentTime)Returnstrueif the cached object is valid.
-
-
-
Constructor Detail
-
CachedObject
public CachedObject(V object, long timestamp, long expirationTime)
Creates a new cached object.- Parameters:
object- The cached object. Must not benull.timestamp- The caching timestamp, in milliseconds since the Unix epoch.expirationTime- The expiration time, in milliseconds since the Unix epoch.
-
-
Method Detail
-
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.
-
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)
Returnstrueif the cached object is valid.- Parameters:
currentTime- The current time, in milliseconds since the Unix epoch.- Returns:
trueif the cached object is valid, elsefalse.
-
isExpired
public boolean isExpired(long currentTime)
Returnstrueif the cached object expired.- Parameters:
currentTime- The current time, in milliseconds since the Unix epoch.- Returns:
trueif the cached object expired, elsefalse.
-
-