Comments (2)
I'm not sure what would be a good, generic C interface for asynchronous operations so async mechanisms are currently left to the users to implement. It's possible to do it using omcache_command
and omcache_io
similar to how the Python client does it.
Also, in case you're not interested in command statuses and just want to push updates to the servers (and potentially wait for operations to complete or fail without distinguishing between the results) it's possible to just use the plain command api (omcache_set
and friends) with a zero timeout and later on call omcache_io
to make sure all commands were sent. This is what https://github.com/ohmu/pgmemcache/ does by default.
from omcache.
Ok, I will do.
For google indexing for people, who searches async memcached c++ interface.
struct protocol_binary_set_request_body_s {
uint32_t flags;
uint32_t expiration;
} __attribute__((packed));
static int async_omc_set_cmd(omcache_t *mc, protocol_binary_command opcode,
const unsigned char *key, size_t key_len,
const unsigned char *value, size_t value_len,
protocol_binary_set_request_body_s* expiration_and_flags,
uint64_t cas,
omcache_req_t *requests,
size_t *req_count,
omcache_value_t *values,
size_t *value_count,
int32_t timeout_msec)
{
if (req_count == NULL || *req_count == 0)
return OMCACHE_INVALID;
memset(requests, 0, sizeof(*requests) * *req_count);
if (values && value_count)
memset(values, 0, sizeof(*values) * *value_count);
size_t extra_len = sizeof(protocol_binary_set_request_body_s);
if (opcode == PROTOCOL_BINARY_CMD_APPEND || opcode == PROTOCOL_BINARY_CMD_APPENDQ ||
opcode == PROTOCOL_BINARY_CMD_PREPEND || opcode == PROTOCOL_BINARY_CMD_PREPENDQ)
extra_len = 0;
omcache_req_t& req = requests[0];
req.server_index = -1;
req.header.opcode = opcode;
req.header.extlen = extra_len;
req.header.keylen = htobe16(key_len);
req.header.bodylen = htobe32(key_len + value_len + extra_len);
req.header.cas = htobe64(cas);
req.extra = expiration_and_flags;
req.key = key;
req.data = value;
return omcache_command(mc, requests, req_count, values, value_count, timeout_msec);
}
int async_omcache_add(omcache_t *mc,
const unsigned char *key, size_t key_len,
const unsigned char *value, size_t value_len,
protocol_binary_set_request_body_s* expiration_and_flags,
omcache_req_t *requests,
size_t *req_count,
omcache_value_t *values,
size_t *value_count,
int32_t timeout_msec)
{
return async_omc_set_cmd(mc, QCMD(PROTOCOL_BINARY_CMD_ADD),
key, key_len, value, value_len,
expiration_and_flags, 0,
requests,
req_count,
values,
value_count,
timeout_msec);
}
int async_omcache_delete(omcache_t *mc,
const unsigned char *key, size_t key_len,
omcache_req_t *requests,
size_t *req_count,
omcache_value_t *values,
size_t *value_count,
int32_t timeout_msec)
{
if (req_count == NULL || *req_count == 0)
return OMCACHE_INVALID;
memset(requests, 0, sizeof(*requests) * *req_count);
if (values && value_count)
memset(values, 0, sizeof(*values) * *value_count);
omcache_req_t *req = &requests[0];
req->server_index = -1;
req->header.opcode = QCMD(PROTOCOL_BINARY_CMD_DELETE);
req->header.keylen = htobe16(key_len);
req->header.bodylen = htobe32(key_len);
req->key = key;
return omcache_command(mc, requests, req_count, values, value_count, timeout_msec);
}
from omcache.
Related Issues (14)
- couple of warnings on clang HOT 2
- CI doesn't run Python tests HOT 3
- Django integration
- Python tests do not run on all supported python versions HOT 2
- Documentation for Python API
- Is this project no longer maintained? HOT 2
- gevent / async support for omcache.py HOT 1
- Malloc checking
- More commands (append, prepend, touch, gat) HOT 2
- Documentation generation HOT 6
- Replace fd_map array with a hash table HOT 1
- Asynchronous name resolution HOT 2
- travis.ci (or something else) to verify tests are passing? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from omcache.