Couchbase C Client  2.4.4
Inspect item's Replication and Persistence

Detailed Description

Determine if an item exists and if it has been replicated and persisted to various nodes.

Functions

lcb_observe_callback lcb_set_observe_callback (lcb_t, lcb_observe_callback)
 
lcb_error_t lcb_observe (lcb_t instance, const void *command_cookie, lcb_SIZE num, const lcb_observe_cmd_t *const *commands)
 Observe key. More...
 

Macros

#define LCB_OBSERVE_FIELDS_COMMON
 

Typedefs

typedef void(* lcb_observe_callback )(lcb_t instance, const void *cookie, lcb_error_t error, const lcb_observe_resp_t *resp)
 The callback function for an observe request. More...
 

Enumerations

enum  lcb_observe_options_t
 
enum  lcb_observe_t
 Possible statuses for keys in OBSERVE response. More...
 

Function Documentation

lcb_error_t lcb_observe ( lcb_t  instance,
const void *  command_cookie,
lcb_SIZE  num,
const lcb_observe_cmd_t *const *  commands 
)

Observe key.

lcb_observe_cmd_t *observe = calloc(1, sizeof(*observe));
observe->version = 0;
observe->v.v0.key = "my-key";
observe->v.v0.nkey = strlen(observe->v.v0.key);
lcb_observe_cmd_t* commands[] = { observe };
lcb_observe(instance, NULL, 1, commands);
Parameters
instancethe instance used to batch the requests from
command_cookieA cookie passed to all of the notifications from this command
numthe total number of elements in the commands array
commandsthe array containing the items to observe
Returns
The status of the operation
Stability
Committed:

Data Structure Documentation

struct lcb_OBSERVECMDv1

lcb_observe() Command structure

Data Fields
const void * key
lcb_SIZE nkey
LCB__HKFIELDS lcb_observe_options_t options <@private
struct lcb_observe_cmd_t

lcb_observe() Command wrapper structure

See also
lcb_OBSERVECMDv1
Data Fields
int version
union lcb_observe_cmd_t v
struct lcb_OBSERVERESPv0

Response Structure for lcb_observe()

Data Fields
const void * key
lcb_SIZE nkey
lcb_cas_t cas CAS of the item on this server.
lcb_observe_t status Status flags.
int from_master zero if key came from replica
lcb_time_t ttp average time to persist on this server
lcb_time_t ttr average time to replicate on this server

Typedef Documentation

typedef void(* lcb_observe_callback)(lcb_t instance, const void *cookie, lcb_error_t error, const lcb_observe_resp_t *resp)

The callback function for an observe request.

Parameters
instancethe instance performing the operation
cookiethe cookie associated with with the command
errorThe status of the operation
respMore information about the operation (only key and nkey is valid if error != LCB_SUCCESS)

Enumeration Type Documentation

Enumerator
LCB_OBSERVE_MASTER_ONLY 

Only sends a command to the master.

In this case the callback will be invoked only once for the master, and then another time with the NULL callback

Possible statuses for keys in OBSERVE response.

Enumerator
LCB_OBSERVE_FOUND 

The item found in the memory, but not yet on the disk.

LCB_OBSERVE_PERSISTED 

The item hit the disk.

LCB_OBSERVE_NOT_FOUND 

The item missing on the disk and the memory.

LCB_OBSERVE_LOGICALLY_DELETED 

No knowledge of the key :)