Package com.couchbase.client.core.api.kv
Class CoreExpiry
java.lang.Object
com.couchbase.client.core.api.kv.CoreExpiry
A relative or absolute expiry.
Exactly one of relative or absolute is non-null,
except for the special NONE instance, which has null for both.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final InstantEarliest expiry instant that can be represented in the Memcached binary protocol.static final InstantLatest expiry instant that can be represented in the Memcached binary protocol.static final CoreExpiryA "null object" that represents the absence of an expiry. -
Method Summary
Modifier and TypeMethodDescriptionabsolute()booleanisNone()static CoreExpiryReturnsNONEif the duration is zero, otherwise a relative CoreExpiry with this duration.static CoreExpiryReturnsNONEif the instant's epoch second is zero, otherwise an absolute CoreExpiry with this instant.relative()toString()void
-
Field Details
-
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
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
A "null object" that represents the absence of an expiry.Its
isNone()method returns true. Itsabsolute()andrelativemethods both return null.
-
-
Method Details
-
of
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
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:
-
isNone
public boolean isNone() -
relative
-
absolute
-
when
-
toString
-