getAndTouch() to collection default TTL value

Hi, we have a requirement that documents in a specific collection have an expiry of 2 years vs other documents in a different collection which have no expiry, and the TTL on these collections are set accordingly 63120000s vs 0s.

We want to avoid having custom logic for these collections and to retrieve all documents using getAndTouch() which we want to reset the expiry to their collection defaults.

Currently we can achieve this by setting the expiry to 0 → getAndTouch(id, Duration.ZERO) which for the documents in the no-expiry collection does just that and for the documents in the collection with a 2 years TTL, expiry will reset to the collection TTL.

My question is, is this expected behaviour and is there a better way to getAndTouch(id) without explicitly setting the expiry so that it just resets to the collection TTL set?

Also explore eventing Document Expiry | Couchbase Docs

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.