Open
Description
I noticed that in the buildUpsertOptions and
buildInsertOptions methods, the doc.getExpiration() value is always converted to seconds using Duration.ofSeconds().
else if (doc.getExpiration() != 0) {
options.expiry(Duration.ofSeconds(doc.getExpiration()));
}
While options.expiry() can accept both Duration and Instant, converting the expiration exclusively to seconds can lead to limitations, especially for setting expirations greater than 50 years. This is because Couchbase supports durations up to 50 years when expressed as seconds, but longer durations must be provided as an Instant.
Suggestion
if (doc.getExpiration() > MAX_SECONDS_EXPIRATION) {
options.expiry(Instant.ofEpochSecond(doc.getExpiration()));
} else {
options.expiry(Duration.ofSeconds(doc.getExpiration()));
}
Does this approach align with the intended design of the buildUpsertOptions and buildInsertOptions methods, or are there other considerations that necessitate the current implementation?
Looking forward to your feedback and insights!