Couchbase C Client
2.5.6
|
Operate on one or more key values.
The key-value APIs are high performance APIs utilizing the memcached protocol. Use these APIs to access data by its unique key.
These APIs are designed so that each function is passed in one or more "Command Structures". A command structure is a small structure detailing a specific key and contains options and modifiers for the operation as it relates to that key.
All the command structures are currently layed out like so:
These top level structures are wrapper structures and are present to ensure portability between different versions of the library. To employ these structures within the command, you may do:
Functions | |
lcb_get_callback | lcb_set_get_callback (lcb_t, lcb_get_callback callback) |
Set the callback to be invoked when an item is received as a result of an lcb_get() operation. More... | |
lcb_error_t | lcb_get (lcb_t instance, const void *command_cookie, lcb_SIZE num, const lcb_get_cmd_t *const *commands) |
Get a number of values from the cache. More... | |
Typedefs | |
typedef void(* | lcb_get_callback) (lcb_t instance, const void *cookie, lcb_error_t error, const lcb_get_resp_t *resp) |
The callback function for a "get-style" request. More... | |
lcb_get_callback lcb_set_get_callback | ( | lcb_t | , |
lcb_get_callback | callback | ||
) |
lcb_error_t lcb_get | ( | lcb_t | instance, |
const void * | command_cookie, | ||
lcb_SIZE | num, | ||
const lcb_get_cmd_t *const * | commands | ||
) |
Get a number of values from the cache.
If you specify a non-zero value for expiration, the server will update the expiration value on the item (refer to the documentation on lcb_store to see the meaning of the expiration). All other members should be set to zero.
It is possible to get an item with a lock that has a timeout. It can then be unlocked with either a CAS operation or with an explicit unlock command.
You may specify the expiration value for the lock in the expiration (setting it to 0 cause the server to use the default value).
Get and lock the key:
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 get |
Operation-specific errors received in callbacks include:
lock
option was set in the command and the item was already locked.struct lcb_GETCMDv0 |
Get Command Structure.
Data Fields | ||
---|---|---|
const void * | key | Key to retrieve. |
lcb_SIZE | nkey | Key length. |
lcb_time_t | exptime |
If this parameter is specified and lock is not set then the server will also update the object's expiration time while retrieving the key. If |
int | lock |
If this parameter is set then the server will in addition to retrieving the item also lock the item, making it so that subsequent attempts to lock and/or modify the same item will fail with an error (either LCB_KEY_EEXISTS or LCB_ETMPFAIL). The lock will be released when one of the following happens:
|
struct lcb_get_cmd_t |
lcb_get() Command Wrapper Structure
Data Fields | ||
---|---|---|
int | version | |
union lcb_get_cmd_t | v |
struct lcb_GETRESPv0 |
struct lcb_get_resp_t |
lcb_get() response wrapper structure
Data Fields | ||
---|---|---|
int | version | |
union lcb_get_resp_t | v |
typedef void(* lcb_get_callback) (lcb_t instance, const void *cookie, lcb_error_t error, const lcb_get_resp_t *resp) |
The callback function for a "get-style" request.
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 actual item (only key and nkey is valid if error != LCB_SUCCESS ) |