Using SDK 2.4.3, we tried to set a ttl in a JSON Document of couchbase. We tried with 1minute (60 sec).Below sample code -
JsonDocument jdoc = JsonDocument.create (“XYZ”,60,content);
JsonDocument cbNotification = bucket.upsert(jdoc);
I came to know that rather than directly removing doc from CouchBase on expiry of TTL, CB waits for getting searched again, which will trigger the deletion upon expiration. I tried multiple time and checked but its not happening. Am I missing something?
Please help and thanks in advance.
@tanban1990 don’t try to view it on the UI, rather perform a kv get operation and see if it returns null. It should be at least, since we got a couple of test cases in our integration test suite and they pass
Gotch the problem.but need solution from you guys…
I am creating entry in couchbase with upsert i.e
JsonDocument jDocs = JsonDocument.create(“key”,ttl,value)
And again via a separate flow i am using upsert again with same TTL value to update the entry.
As I found out this --“the 2nd upsert resets the TTL - and the document will never expire.”, Is my analysis proper?Is this the reason my entries are not getting expired?Will the second upsert reset the TTL even though we provide TTL value explicitly?If yes, then how to restore the TTL value rather than resetting it with 2nd upsert?