How to set TTL (Time to Live) for a specific couchbase document using spring-data-couchbase? I know there is way to set expiry time using Document notation as follows @Docum
Using Spring-Data-Couchbase, you cannot set a TTL on a particular instance. Inserting (mutating) and setting the TTL in one go would be quite complicated given the transcoding steps that are hidden away in the CouchbaseTemplate save method.
However, if what you want to do is just update the TTL of an already persisted document (which is what getAndTouch does), there is a way that doesn't involve any transcoding and so can be applied easily:
CouchbaseTemplate, get access to the underlying SDK client via getCouchbaseClient() (note for now sdc is built on top of the previous generation of SDK, 1.4.x, but there'll be a preview of sdc-2.0 soon ;) )touch operation on the document's ID, give it the new TTLtouch() method returns an OperationFuture (it is async), so make sure to either block on it or consider the touch done only if notified so in the callback.