0.39
+* Add support for prefix keys to binary protocol.
+
* Remove the undocumented call memcached_server_remove().
* The undocumented call memcached_server_by_key() now returns const.
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= cmd;
- request.message.header.request.keylen= htons((uint16_t) key_length);
+ request.message.header.request.keylen= htons((uint16_t)(key_length + ptr->prefix_key_length));
request.message.header.request.extlen= 20;
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- request.message.header.request.bodylen= htonl((uint32_t) (key_length + request.message.header.request.extlen));
+ request.message.header.request.bodylen= htonl((uint32_t)(key_length + ptr->prefix_key_length + request.message.header.request.extlen));
request.message.body.delta= htonll(offset);
request.message.body.initial= htonll(initial);
request.message.body.expiration= htonl((uint32_t) expiration);
memcached_return_t rc;
- if (((rc= memcached_do(instance, request.bytes,
- sizeof(request.bytes), false)) != MEMCACHED_SUCCESS) ||
+ if (((rc= memcached_do(instance, request.bytes, sizeof(request.bytes), false)) != MEMCACHED_SUCCESS) ||
+ (memcached_io_write(instance, ptr->prefix_key, ptr->prefix_key_length, false) == -1) ||
(memcached_io_write(instance, key, key_length, true) == -1))
{
memcached_io_reset(instance);
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ;
else
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETE;
- request.message.header.request.keylen= htons((uint16_t)key_length);
+ request.message.header.request.keylen= htons((uint16_t)(key_length + ptr->prefix_key_length));
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- request.message.header.request.bodylen= htonl((uint32_t) key_length);
+ request.message.header.request.bodylen= htonl((uint32_t)(key_length + ptr->prefix_key_length));
if (ptr->flags.use_udp && ! flush)
{
memcached_return_t rc= MEMCACHED_SUCCESS;
- if (((rc= memcached_do(instance, request.bytes,
- sizeof(request.bytes), false)) != MEMCACHED_SUCCESS) ||
- (memcached_io_write(instance, key,
- key_length, flush) == -1))
+ if (((rc= memcached_do(instance, request.bytes, sizeof(request.bytes), false)) != MEMCACHED_SUCCESS) ||
+ (memcached_io_write(instance, ptr->prefix_key, ptr->prefix_key_length, false) == -1) ||
+ (memcached_io_write(instance, key, key_length, flush) == -1))
{
memcached_io_reset(instance);
rc= (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc;
{
memcached_result_st *result= &ptr->result;
memcached_return_t rc= MEMCACHED_FAILURE;
- unsigned int x;
while ((result= memcached_fetch_result(ptr, result, &rc)) != NULL)
{
if (rc == MEMCACHED_SUCCESS)
{
- for (x= 0; x < number_of_callbacks; x++)
+ for (uint32_t x= 0; x < number_of_callbacks; x++)
{
rc= (*callback[x])(ptr, result, context);
if (rc != MEMCACHED_SUCCESS)
return vk;
}
- request.message.header.request.keylen= htons((uint16_t)key_length[x]);
+ request.message.header.request.keylen= htons((uint16_t)(key_length[x] + ptr->prefix_key_length));
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- request.message.header.request.bodylen= htonl((uint32_t) key_length[x]);
+ request.message.header.request.bodylen= htonl((uint32_t)( key_length[x] + ptr->prefix_key_length));
- if ((memcached_io_write(instance, request.bytes,
- sizeof(request.bytes), false) == -1) ||
- (memcached_io_write(instance, keys[x],
- key_length[x], flush) == -1))
+ if (memcached_io_write(instance, request.bytes, sizeof(request.bytes), false) == -1)
+ {
+ memcached_server_response_reset(instance);
+ rc= MEMCACHED_SOME_ERRORS;
+ continue;
+ }
+
+ if (ptr->prefix_key_length)
+ {
+ if (memcached_io_write(instance, ptr->prefix_key, ptr->prefix_key_length, false) == -1)
+ {
+ memcached_server_response_reset(instance);
+ rc= MEMCACHED_SOME_ERRORS;
+ continue;
+ }
+ }
+
+ if (memcached_io_write(instance, keys[x], key_length[x], flush) == -1)
{
memcached_server_response_reset(instance);
rc= MEMCACHED_SOME_ERRORS;
/* We just want one pending response per server */
memcached_server_response_reset(instance);
memcached_server_response_increment(instance);
- if ((x > 0 && x == ptr->io_key_prefetch) &&
- memcached_flush_buffers(ptr) != MEMCACHED_SUCCESS)
+ if ((x > 0 && x == ptr->io_key_prefetch) && memcached_flush_buffers(ptr) != MEMCACHED_SUCCESS)
+ {
rc= MEMCACHED_SOME_ERRORS;
+ }
}
if (mget_mode)
.message.header.request= {
.magic= PROTOCOL_BINARY_REQ,
.opcode= PROTOCOL_BINARY_CMD_GETK,
- .keylen= htons((uint16_t)key_length[x]),
+ .keylen= htons((uint16_t)(key_length[x] + ptr->prefix_key_length)),
.datatype= PROTOCOL_BINARY_RAW_BYTES,
- .bodylen= htonl((uint32_t)key_length[x])
+ .bodylen= htonl((uint32_t)(key_length[x] + ptr->prefix_key_length))
}
};
* that we might have processed some of the responses etc. For now,
* just make sure we work _correctly_
*/
- if ((memcached_io_write(instance, request.bytes,
- sizeof(request.bytes), false) == -1) ||
- (memcached_io_write(instance, keys[x],
- key_length[x], true) == -1))
+ if ((memcached_io_write(instance, request.bytes, sizeof(request.bytes), false) == -1) ||
+ (memcached_io_write(instance, ptr->prefix_key, ptr->prefix_key_length, false) == -1) ||
+ (memcached_io_write(instance, keys[x], key_length[x], true) == -1))
{
memcached_io_reset(instance);
dead_servers[server]= true;
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
request.message.header.request.opcode= get_com_code(verb, noreply);
- request.message.header.request.keylen= htons((uint16_t)key_length);
+ request.message.header.request.keylen= htons((uint16_t)(key_length + ptr->prefix_key_length));
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
if (verb == APPEND_OP || verb == PREPEND_OP)
send_length -= 8; /* append & prepend does not contain extras! */
request.message.body.expiration= htonl((uint32_t)expiration);
}
- request.message.header.request.bodylen= htonl((uint32_t) (key_length + value_length +
+ request.message.header.request.bodylen= htonl((uint32_t) (key_length + ptr->prefix_key_length + value_length +
request.message.header.request.extlen));
if (cas)
memcached_return_t rc;
if (((rc= memcached_do(server, (const char*)request.bytes,
send_length, false)) != MEMCACHED_SUCCESS) ||
+ (memcached_io_write(server, ptr->prefix_key, ptr->prefix_key_length, false) == -1) ||
(memcached_io_write(server, key, key_length, false) == -1) ||
(memcached_io_write(server, value, value_length, flush) == -1))
{