Atomic counter operations.
Increment or decrement a numerical item within the cluster.
lcb_error_t lcb_arithmetic |
( |
lcb_t |
instance, |
|
|
const void * |
command_cookie, |
|
|
lcb_SIZE |
num, |
|
|
const lcb_arithmetic_cmd_t *const * |
commands |
|
) |
| |
Perform arithmetic operation on a keys value.
You should initialize the key, nkey and expiration member in the lcb_item_st structure for the keys to update. Values larger than 30*24*60*60 seconds (30 days) are interpreted as absolute times (from the epoch). All other members should be set to zero.
lcb_arithmetic_cmd_t *arithmetic = calloc(1, sizeof(*arithmetic));
arithmetic->version = 0;
arithmetic->v.v0.key = "counter";
arithmetic->v.v0.nkey = strlen(arithmetic->v.v0.key);
arithmetic->v.v0.initial = 0x666;
arithmetic->v.v0.create = 1;
arithmetic->v.v0.delta = 1;
lcb_arithmetic_cmd_t* commands[] = { arithmetic };
- Parameters
-
instance | the handle to lcb |
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 operate on |
- Returns
- Status of the operation.
- Stability
- Committed:
typedef void(* lcb_arithmetic_callback) (lcb_t instance, const void *cookie, lcb_error_t error, const lcb_arithmetic_resp_t *resp) |
The callback function for an arithmetic request.
- Parameters
-
instance | the instance performing the operation |
cookie | the cookie associated with with the command |
error | The status of the operation |
resp | More information about the operation (only key and nkey is valid if error != LCB_SUCCESS) |
- Stability
- Committed: