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.
Cached object.
- Version:
- 2024-04-20
-
Constructor Summary
ConstructorsConstructorDescriptionCachedObject
(V object, long timestamp, long expirationTime) Creates a new cached object. -
Method Summary
Modifier and TypeMethodDescriptionstatic long
computeExpirationTime
(long currentTime, long timeToLive) Computes expiration time.get()
Returns the cached object.long
Returns the expiration time.long
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 Details
-
CachedObject
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 Details
-
computeExpirationTime
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
Returns the cached object.- Returns:
- The cached object.
-
getTimestamp
Returns the caching timestamp.- Returns:
- The caching timestamp, in milliseconds since the Unix epoch.
-
getExpirationTime
Returns the expiration time.- Returns:
- The expiration time, in milliseconds since the Unix epoch.
-
isValid
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
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
.
-