Couchbase C Client
3.3.14
Asynchronous C Client for Couchbase
|
Associate user-defined data with operations
User-defined pointers may be passed to all operations in the form of a cookie
parameter. This cookie parameter allows any kind of application context to be accessible via the callback (in lcb_RESPBASE::cookie).
The library will not inspect or manage the address or contents of the cookie; it may live on the stack (especially if using the library synchronously), on the heap, or may be NULL altogether.
In addition to per-operation cookies, the library allows the instance itself (i.e. the lcb_INSTANCE
object) to contain its own cookie. This is helpful when there is a wrapper object which needs to be accessed from within the callback
void lcb_set_cookie | ( | lcb_INSTANCE * | instance, |
const void * | cookie ) |
Associate a cookie with an instance of lcb.
The cookie is a user defined pointer which will remain attached to the specified lcb_INSTANCE
for its duration. This is the way to associate user data with the lcb_INSTANCE
.
instance | the instance to associate the cookie to |
cookie | the cookie to associate with this instance. |
cookie
stored with the instance; thus you must ensure to manually free resources to the pointer (if it was dynamically allocated) when it is no longer required. const void * lcb_get_cookie | ( | lcb_INSTANCE * | instance | ) |
Retrieve the cookie associated with this instance.
instance | the instance of lcb |