#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#define PRIx64 "I64x"
#else
#include <inttypes.h>
#endif
{
exit(EXIT_FAILURE);
}
{
if (rc == LCB_SUCCESS) {
const char *key;
size_t nkey;
uint64_t cas;
lcb_respstore_key(resp, &key, &nkey);
fprintf(stderr, "KEY: %.*s\n", (int)nkey, key);
lcb_respstore_cas(resp, &cas);
fprintf(stderr, "CAS: 0x%" PRIx64 "\n", cas);
} else {
}
}
{
if (rc == LCB_SUCCESS) {
const char *key, *value;
size_t nkey, nvalue;
uint64_t cas;
uint32_t flags;
lcb_respget_key(resp, &key, &nkey);
fprintf(stderr, "KEY: %.*s\n", (int)nkey, key);
lcb_respget_cas(resp, &cas);
fprintf(stderr, "CAS: 0x%" PRIx64 "\n", cas);
lcb_respget_value(resp, &value, &nvalue);
lcb_respget_flags(resp, &flags);
fprintf(stderr, "VALUE: %.*s\n", (int)nvalue, value);
fprintf(stderr, "FLAGS: 0x%x\n", flags);
} else {
}
}
int main(int argc, char *argv[])
{
lcb_CREATEOPTS *create_options = NULL;
lcb_CMDSTORE *scmd;
lcb_CMDGET *gcmd;
if (argc < 2) {
fprintf(stderr, "Usage: %s couchbase://host/bucket [ password [ username ] ]\n", argv[0]);
exit(EXIT_FAILURE);
}
lcb_createopts_connstr(create_options, argv[1], strlen(argv[1]));
if (argc > 3) {
lcb_createopts_credentials(create_options, argv[2], strlen(argv[2]), argv[3], strlen(argv[3]));
}
lcb_createopts_destroy(create_options);
if (err != LCB_SUCCESS) {
die(NULL, "Couldn't create couchbase handle", err);
}
if (err != LCB_SUCCESS) {
die(instance, "Couldn't schedule connection", err);
}
if (err != LCB_SUCCESS) {
die(instance, "Couldn't bootstrap from cluster", err);
}
lcb_cmdstore_key(scmd, "key", strlen("key"));
lcb_cmdstore_value(scmd, "value", strlen("value"));
err = lcb_store(instance, NULL, scmd);
lcb_cmdstore_destroy(scmd);
if (err != LCB_SUCCESS) {
die(instance, "Couldn't schedule storage operation", err);
}
fprintf(stderr, "Will wait for storage operation to complete..\n");
lcb_cmdget_create(&gcmd);
lcb_cmdget_key(gcmd, "key", strlen("key"));
err = lcb_get(instance, NULL, gcmd);
if (err != LCB_SUCCESS) {
die(instance, "Couldn't schedule retrieval operation", err);
}
lcb_cmdget_destroy(gcmd);
fprintf(stderr, "Will wait to retrieve item..\n");
return 0;
}