Mutate an item within the cluster.
Here you can create a new item, replace an existing item, and append or prepend to an existing value
Store an item in the cluster.
You may initialize all of the members in the the lcb_item_st structure with the values you want. Values larger than 30*24*60*60
seconds (30 days) are interpreted as absolute times (from the epoch). Unused members should be set to zero.
lcb_store_cmd_st *store = calloc(1, sizeof(*store));
store->version = 0;
store->v.v0.key = "my-key";
store->v.v0.nkey = strlen(store->v.v0.key);
store->v.v0.bytes = "{ value:666 }"
store->v.v0.nbytes = strlen(store->v.v0.bytes);
store->v.v0.flags = 0xdeadcafe;
store->v.v0.cas = 0x1234;
store->v.v0.exptime = 0x666;
store->v.v0.datatype = LCB_JSON;
lcb_store_cmd_st* commands[] = { store };
- Parameters
-
instance | the instance used to batch the requests from |
command_cookie | A cookie passed to all of the notifications from this command |
num | the total number of elements in the commands array |
commands | the array containing the items to store |
- Returns
- The status of the operation
- Stability
- Committed:
- Examples:
- example/libeventdirect/main.c, and example/minimal/minimal.c.
lcb_store() Command structure
This structure is used to define an item to be stored on the server.
Data Fields |
const void * |
key |
|
lcb_SIZE |
nkey |
|
const void * |
bytes |
Value to store. |
lcb_SIZE |
nbytes |
Length of value to store. |
lcb_U32 |
flags |
User-defined flags stored along with the item. |
lcb_cas_t |
cas |
If present, the server will check that the item's current CAS matches the value specified here. If this check fails the command will fail with an LCB_KEY_EEXISTS error.
- Warning
- For LCB_APPEND and LCB_PREPEND, this field should be
0 .
|
lcb_U8 |
datatype |
See lcb_VALUEFLAGS. |
lcb_time_t |
exptime |
Expiration for the item. 0 means never expire.
- Warning
- for LCB_APPEND and LCB_PREPEND, this field should be
0 .
|
lcb_storage_t |
operation |
Mandatory. Mutation type
|
The callback function for a storage request.
- Parameters
-
instance | the instance performing the operation |
operation | the operation performed |
cookie | the cookie associated with with the command |
error | The status of the operation |
resp | More information about the item related to the store operation. (only key and nkey is valid if error != LCB_SUCCESS) |
- Stability
- Committed:
operation
parameter for lcb_store()
Storing an item in couchbase is only one operation with a different set of attributes / constraints.
Enumerator |
---|
LCB_ADD |
Add the item to the cache, but fail if the object exists alread.
|
LCB_REPLACE |
Replace the existing object in the cache.
|
LCB_SET |
Unconditionally set the object in the cache.
|
LCB_APPEND |
Append this object to the existing object.
|
LCB_PREPEND |
Prepend this object to the existing object.
|