Package com.couchbase.client.core.api.kv
Class CoreExpiry
- java.lang.Object
-
- com.couchbase.client.core.api.kv.CoreExpiry
-
-
Field Summary
Fields Modifier and Type Field Description static InstantEARLIEST_VALID_EXPIRY_INSTANTEarliest expiry instant that can be represented in the Memcached binary protocol.static InstantLATEST_VALID_EXPIRY_INSTANTLatest expiry instant that can be represented in the Memcached binary protocol.static CoreExpiryNONEA "null object" that represents the absence of an expiry.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Instantabsolute()booleanisNone()static CoreExpiryof(Duration duration)ReturnsNONEif the duration is zero, otherwise a relative CoreExpiry with this duration.static CoreExpiryof(Instant instant)ReturnsNONEif the instant's epoch second is zero, otherwise an absolute CoreExpiry with this instant.Durationrelative()StringtoString()voidwhen(Consumer<Instant> ifAbsolute, Consumer<Duration> ifRelative, Runnable ifNone)
-
-
-
Field Detail
-
LATEST_VALID_EXPIRY_INSTANT
public static final Instant LATEST_VALID_EXPIRY_INSTANT
Latest expiry instant that can be represented in the Memcached binary protocol.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.
-
EARLIEST_VALID_EXPIRY_INSTANT
public static final Instant EARLIEST_VALID_EXPIRY_INSTANT
Earliest expiry instant that can be represented in the Memcached binary protocol.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.
-
NONE
public static final CoreExpiry NONE
A "null object" that represents the absence of an expiry.Its
isNone()method returns true. Itsabsolute()andrelativemethods both return null.
-
-
Method Detail
-
of
public static CoreExpiry of(Duration duration)
ReturnsNONEif the duration is zero, otherwise a relative CoreExpiry with this duration.- Throws:
InvalidArgumentException- if duration is non-zero and less than 1 second.
-
of
public static CoreExpiry of(Instant instant)
ReturnsNONEif the instant's epoch second is zero, otherwise an absolute CoreExpiry with this instant.- Throws:
InvalidArgumentException- if instant is non-zero and outside the valid range.- See Also:
EARLIEST_VALID_EXPIRY_INSTANT,LATEST_VALID_EXPIRY_INSTANT
-
isNone
public boolean isNone()
-
when
public void when(Consumer<Instant> ifAbsolute, Consumer<Duration> ifRelative, Runnable ifNone)
-
-