observe callback

hello, i use c sdk.
execute lcb_observe, observe_callback be executed three times, why?
and lcb_observe_resp_t.v.v0.status are differents, but the last value is LCB_OBSERVE_FOUND always.
actually the key has been deleted.

From libcouchbase 2.1.0 there is new interface lcb_durability_poll which is higher level abstraction for implementing durability requirements. You can read more in the corresponding man page

1 Answer

« Back to question.

I chuckled at this one.

If you head over to the definition of LCB_OBSERVE_FOUND in <libcouchbase/types.h>, you'll see something like this LCB_OBSERVE_FOUND = 0x00

The observe callback is invoked the last time with what's called a "NULL" response. This response contains NULL for key, 0 for nkey etc. etc. and signals that there are no longer any OBSERVE responses for the particular operation (typically defined by the cookie) to be invoked.

You are likely not checking for this condition and only inspecting the status field, which is of course 0 - and is the meaning of LCB_OBSERVE_FOUND