Reading the expiraration time of counters
I'm using Libcouchbase in C 2.0.7, I access counters from multiple processes and threads. We need to count the number of specific operations over different time periods. We use an expiration time on the counter to do that. Later we pull out the value. However we found some times we managed to create the counter with no expiration.
We do creation (and increment) as a two phase process:
lcb_increment (+delta, but no expiration)
lcb_touch to set the expiration time
Occasionally we get error 23 (timeout) returned, in in that case we don't call lcb_touch().
However in Couchbase I can see the counter was successfully created, so it seems we timeout waiting for a response.
I can see that when I increase the timeout value my problem goes away, but I'm trying to see if make the code a little safer.
If I pass a exptime on lcb_increment() will this always modifty the expiration time, or does extime on lcb_increment() only take effect of a new creation ?.
Is there any way I can read the expiration time, if I could do this I could read the counter exptime when doing lcb_get() and then delete the counter if it has no exptime. However I looked over the API definition and I can't see a way to read the expiration time.
Any thoughs, Fitz.
First of all, I am not a C developer so my answer will be based on the generic Couchbase/Memcache protocol and its behavior.
Operations, including increment are not by default changing the TTL, if you want to modify it/reset it you need to explicitluy do it when you call the operation.
The standard operations do not expose any method to read the TTL from the meta data. (no official way at least)