@Stability.Internal public final class CoreExpiry extends Object
| Modifier and Type | Field and Description |
|---|---|
static Instant |
EARLIEST_VALID_EXPIRY_INSTANT
Earliest expiry instant that can be represented in the Memcached binary protocol.
|
static Instant |
LATEST_VALID_EXPIRY_INSTANT
Latest expiry instant that can be represented in the Memcached binary protocol.
|
static CoreExpiry |
NONE
A "null object" that represents the absence of an expiry.
|
| Modifier and Type | Method and Description |
|---|---|
Instant |
absolute() |
boolean |
isNone() |
static CoreExpiry |
of(Duration duration)
Returns
NONE if the duration is zero, otherwise a relative CoreExpiry with this duration. |
static CoreExpiry |
of(Instant instant)
Returns
NONE if the instant's epoch second is zero, otherwise an absolute CoreExpiry with this instant. |
Duration |
relative() |
String |
toString() |
void |
when(Consumer<Instant> ifAbsolute,
Consumer<Duration> ifRelative,
Runnable ifNone) |
public static final Instant LATEST_VALID_EXPIRY_INSTANT
The server interprets the Memcached protocol's 32-bit expiry field as an unsigned integer. This means the maximum value is 4294967295 seconds, which corresponds to 2106-02-07T06:28:15Z.
public static final Instant EARLIEST_VALID_EXPIRY_INSTANT
A negative instant (before the epoch) could be misinterpreted as in the future. An instant within 30 days after the epoch would be misinterpreted as a relative expiry.
Fortunately, setting a document's expiry this far in the past is almost certainly a programming error, so it's fine for the SDK to throw an exception.
public static final CoreExpiry NONE
Its isNone() method returns true.
Its absolute() and relative methods both return null.
public static CoreExpiry of(Duration duration)
NONE if the duration is zero, otherwise a relative CoreExpiry with this duration.InvalidArgumentException - if duration is non-zero and less than 1 second.public static CoreExpiry of(Instant instant)
NONE if the instant's epoch second is zero, otherwise an absolute CoreExpiry with this instant.InvalidArgumentException - if instant is non-zero and outside the valid range.EARLIEST_VALID_EXPIRY_INSTANT,
LATEST_VALID_EXPIRY_INSTANTpublic boolean isNone()
Copyright © 2024 Couchbase, Inc.. All rights reserved.