Couchbase documents expiry getting reduced

I am trying to extend the expiry of my couchbase documents using touchDocument method, the extending is happening and immediately going back to older expiry value. Will there ever be a situation in couchbase when a call to a touchDocument method is not honored?

Is this couchbase-lite/sync-gateway?

Can you describe the exact method you’re using to update these documents? This function name doesn’t align with anything I can find in the Couchbase SDKs, Couchbase Lite, or Sync Gateway APIs.

If it is a Couchbase Server SDK using GetAndTouchDocument, which language?

Sorry, It’s actually touch() method, which takes ID, expiry and TouchOptions as arguments. Language that I am using is Java.

Hi @psruthishalini ,

Welcome to the Couchbase Forum!

Here are some ideas about why it might look like the expiry is not being applied:

  • The Collection.get method does not return the document’s expiry unless you ask for it by setting the withExpiry option to true. If you don’t ask for the expiry, the response is the same as if the document has no expiry: GetResult.expiryTime() returns an empty Optional.

  • A subsequent call to upsert or replace could be setting the expiry to a different value.

  • If a document has an expiry, a subsequent call to upsert or replace for that document clears the expiry, unless you set the preserveExpiry option to true on the upsert / replace request. Same is true for any SQL++ query that modifies the document.

  • If the document lives in a bucket or collection configured with a maxTTL (also known as “max expiry”), the document expiry is capped at the configured max. In other words, if you try to set an expiry longer than the configured max, the expiry is set to the max.

  • If you are using the Reactive API, note that ReactiveCollection.touch() returns a “cold” publisher. In other words, the actual server request is not executed until you subscribe to the Mono returned by ReactiveCollection.touch().

  • If you are using the Reactive or Async APIs, remember that these methods dispatch the request asynchronously. Make sure to to wait for the request to finish before checking the document’s new expiry.