ACID Transaction - Insert Document and set TTL

Hi,

Is there a way to specify document TLL while inserting docs using ACID Transaction. Typically, we use insertOptions to specify the TTL.

MutationResult insertResult = collection.insert(
  "my-document",
  json,
  insertOptions().expiry(Duration.ofHours(2))
);

However, with transactions, I don’t see a way to specify insertOptions.

public com.couchbase.transactions.TransactionGetResult insert(com.couchbase.client.java.Collection collection, String id, Object content)

As a workaround I may be able to run a N1QL query and set the TTL via the query (6.6 feature) but I was wondering if there is a way to do it directly via the transaction insert method.

Thanks…
Amrish

Hi @amrish, expiry/TTL is not supported in our transactions currently. That’s not to say it never will be, but it is not currently on the roadmap.
I’m interested in your the use case for transient documents requiring ACID guarantees, could you possibly elaborate on it?

Hi,

These are not necessarily transient documents. We set a TTL on every document that is inserted in the DB so they get deleted after their required retention period. The specific use case we are dealing with right now requires us act on an incoming document synced via Sync Gateway and has an attachment on it. Our service pulls the attachment from the doc by calling the SG attachment endpoint, sends the attachment to our Document Management System and updates the status of all these operations on a ‘Receipt’ document as well as on the original document that was synced via SG. We update the Receipt doc as well as original doc in a Transaction as they need to reflect a consistent status of operation as several subsequent operations depend on the status being accurate. Once the entire business process is complete we don’t need the ‘receipt’ document or the doc that the mobile synced via SG either.

I’d say that requiring TTL on any docs updated/ inserted via Transactions API is a very reasonable ask. I’ll open a feature request for this…

Regards
Amrish

Hi @amrish
Yes that use case seems a good one, and please do file a feature request on it.