Hi Team,
I am new in couchbase and tried the insert option provided by couchbase sdk to create a document with expiration time of 3 days. This creates a document as expected.
But when I run an update ,it is updating the value in document and also resetting the expiration time to zero.
Code for that
public static void main(String[] args) {
Cluster cluster = Cluster.connect(host, userName, password);
Bucket bucket = cluster.bucket(bucketName);
Collection defaultCollection = bucket.defaultCollection();
//Duration expiry = Duration.ofDays(3l);
//String documentId = "test123#" + System.currentTimeMillis();
//JsonObject jsonDocument = JsonObject.create().put("name", "name1").put("age", 22).put("type", "emp");
//MutationResult mutationResult = defaultCollection.insert(documentId, jsonDocument,
// InsertOptions.insertOptions().expiry(expiry));
String documentId = "test123#1608632063262";
List<MutateInSpec> mutateSpecs = new ArrayList<>();
MutateInSpec ageSpec = MutateInSpec.replace("age", 10);
mutateSpecs.add(ageSpec);
MutateInResult mutationResult = bucket.defaultCollection().mutateIn(documentId, mutateSpecs);
}
I need to update one column in document and hence I am using mutateIn option.
Is it possible avoid resetting the expiration time in this scenario? If so can someone tell me how to do this ?
or if there is an alternate solution let me know. Thanks in advance