Couchbase C Client  2.10.7
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
lcb_touch3
lcb_error_t lcb_touch3(lcb_t instance, const void *cookie, const lcb_CMDTOUCH *cmd)
Spool a touch request.
lcb_CMDBASE::exptime
lcb_U32 exptime
Specify the expiration time.
Definition: couchbase.h:523
lcb_RESPBASE::rc
lcb_error_t rc
Status code.
Definition: couchbase.h:626
LCB_CMD_SET_KEY
#define LCB_CMD_SET_KEY(cmd, keybuf, keylen)
Set the key for the command.
Definition: couchbase.h:556
lcb_t
struct lcb_st * lcb_t
Definition: couchbase.h:41
LCB_SUCCESS
@ LCB_SUCCESS
Success.
Definition: error.h:478
lcb_RESPBASE
Base response structure for callbacks.
Definition: couchbase.h:625
lcb_CMDBASE
Common ABI header for all commands.
Definition: couchbase.h:522
lcb_install_callback3
lcb_RESPCALLBACK lcb_install_callback3(lcb_t instance, int cbtype, lcb_RESPCALLBACK cb)
LCB_CALLBACK_TOUCH
@ LCB_CALLBACK_TOUCH
lcb_touch3()
Definition: couchbase.h:700