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 long
computeExpirationTime(long currentTime, long timeToLive)
Computes expiration time.V
get()
Returns the cached object.long
getExpirationTime()
Returns the expiration time.long
getTimestamp()
Returns the caching timestamp.boolean
isExpired(long currentTime)
Returnstrue
if the cached object expired.boolean
isValid(long currentTime)
Returnstrue
if 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)
Returnstrue
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, elsefalse
.
-
isExpired
public boolean isExpired(long currentTime)
Returnstrue
if the cached object expired.- Parameters:
currentTime
- The current time, in milliseconds since the Unix epoch.- Returns:
true
if the cached object expired, elsefalse
.
-
-