diff options
author | dormando <dormando@rydia.net> | 2011-09-27 00:57:06 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2011-09-27 00:57:06 -0700 |
commit | d87f568a95ed1abe468188476fa5ed9288799223 (patch) | |
tree | ae6717e84ccc88d5869bf9c95b225c3f3eb80543 /testapp.c | |
parent | 51c8f31fc709d06c479de88bdc5e14e757faabc5 (diff) | |
download | memcached-d87f568a95ed1abe468188476fa5ed9288799223.tar.gz |
Backport binary TOUCH/GAT/GATQ commands
Taken from the 1.6 branch, partly written by Trond. I hope the CAS handling is
correct.
Diffstat (limited to 'testapp.c')
-rw-r--r-- | testapp.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -823,6 +823,33 @@ static off_t flush_command(char* buf, size_t bufsz, uint8_t cmd, uint32_t exptim return size; } + +static off_t touch_command(char* buf, + size_t bufsz, + uint8_t cmd, + const void* key, + size_t keylen, + uint32_t exptime) { + protocol_binary_request_touch *request = (void*)buf; + assert(bufsz > sizeof(*request)); + + memset(request, 0, sizeof(*request)); + request->message.header.request.magic = PROTOCOL_BINARY_REQ; + request->message.header.request.opcode = cmd; + + request->message.header.request.keylen = htons(keylen); + request->message.header.request.extlen = 4; + request->message.body.expiration = htonl(exptime); + request->message.header.request.bodylen = htonl(keylen + 4); + + request->message.header.request.opaque = 0xdeadbeef; + + off_t key_offset = sizeof(protocol_binary_request_no_extras) + 4; + + memcpy(buf + key_offset, key, keylen); + return sizeof(protocol_binary_request_no_extras) + 4 + keylen; +} + static off_t arithmetic_command(char* buf, size_t bufsz, uint8_t cmd, @@ -1674,6 +1701,13 @@ static enum test_return test_binary_pipeline_hickup_chunk(void *buffer, size_t b key, keylen, NULL, 0); break; + case PROTOCOL_BINARY_CMD_TOUCH: + case PROTOCOL_BINARY_CMD_GAT: + case PROTOCOL_BINARY_CMD_GATQ: + len = touch_command(command.bytes, sizeof(command.bytes), cmd, + key, keylen, 10); + break; + case PROTOCOL_BINARY_CMD_STAT: len = raw_command(command.bytes, sizeof(command.bytes), PROTOCOL_BINARY_CMD_STAT, |