Couchbase C Client  2.10.3
Asynchronous C Client for Couchbase
Touch/Expiry

Detailed Description

Modify or clear a document's expiration time.

Couchbase allows documents to contain expiration times (see lcb_CMDBASE::exptime). Most operations allow the expiry time to be updated, however lcb_touch3() allows the exclusive update of the expiration time without additional network overhead.

Functions

lcb_error_t lcb_touch3 (lcb_t instance, const void *cookie, const lcb_CMDTOUCH *cmd)
 Spool a touch request. More...
 

Typedefs

typedef lcb_CMDBASE lcb_CMDTOUCH
 Command structure for a touch request. More...
 
typedef lcb_RESPBASE lcb_RESPTOUCH
 Response structure for a touch request. More...
 

Function Documentation

◆ lcb_touch3()

lcb_error_t lcb_touch3 ( lcb_t  instance,
const void *  cookie,
const lcb_CMDTOUCH cmd 
)

Spool a touch request.

Stability
Committed:
Parameters
instancethe handle
cookiethe pointer to associate with the request
cmdthe command
Returns
LCB_SUCCESS on success, other error code on failure
Request
lcb_CMDTOUCH cmd = { 0 };
LCB_CMD_SET_KEY(&cmd, "keep_me", strlen("keep_me"));
cmd.exptime = 0; // Clear the expiration
lcb_touch3(instance, cookie, &cmd);
Response
lcb_install_callback3(instance, LCB_CALLBACK_TOUCH, touch_callback);
void touch_callback(lcb_t instance, int cbtype, const lcb_RESPBASE *rb)
{
if (rb->rc == LCB_SUCCESS) {
printf("Touch succeeded\n");
}
}

Typedef Documentation

◆ lcb_CMDTOUCH

Command structure for a touch request.

Note
The lcb_CMDTOUCH::cas field is ignored. The item's modification time is always updated regardless if the CAS on the server differs. The #exptime field is always used. If 0 then the expiry on the server is cleared.

◆ lcb_RESPTOUCH

Response structure for a touch request.

Note
the lcb_RESPTOUCH::cas field contains the current CAS of the item