Context
I’m migrating to Spring 3.x and using Couchbase transactions for atomic updates. I need to set a TTL/expiry on documents as part of the transactional upsert, but it appears that setting expiry within a transaction is either disallowed in Spring Data 3.x.
Environment
-
Couchbase Server: Enterprise Edition 7.2.5
-
Java:
21 -
Spring Boot:
3.5.9 -
Couchbase Client:
3.5.3
What I’m trying to do
Within a transaction, upsert a document and set its expiry based on a calculated duration:
Java
return repository.getOperations()
.upsertById(MyDomainClass.class)
.withExpiry(calculateDurationFromNow(getDateTime(domainObjectExpiryTime)))
.one(myDomainObject);
Questions
-
Is setting document expiry inside transactions supported by Couchbase when using Spring Data Couchbase 3.x?
-
If not supported, is there a recommended pattern to apply TTL atomically with transactional writes (e.g., post-commit mutation, separate non-transactional write, or using a different operation)?
-
Are there configuration flags or SDK-level calls that enable expiry within transactions?
Thanks!