#include "common.h"
-static memcached_return_t memcached_auto(memcached_st *ptr,
+static memcached_return_t text_incr_decr(memcached_st *ptr,
const char *verb,
const char *master_key, size_t master_key_length,
const char *key, size_t key_length,
instance= memcached_server_instance_fetch(ptr, server_key);
send_length= (size_t)snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "%s %s%.*s %" PRIu64 "%s\r\n", verb,
+ "%s %.*s%.*s %" PRIu64 "%s\r\n", verb,
+ (int)ptr->prefix_key_length,
ptr->prefix_key,
(int)key_length, key,
offset, no_reply ? " noreply" : "");
unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
- rc= memcached_do(instance, buffer, send_length, 1);
+ rc= memcached_do(instance, buffer, send_length, true);
if (no_reply || rc != MEMCACHED_SUCCESS)
return rc;
request.message.body.expiration= htonl((uint32_t) expiration);
if ((memcached_do(instance, request.bytes,
- sizeof(request.bytes), 0)!=MEMCACHED_SUCCESS) ||
- (memcached_io_write(instance, key, key_length, 1) == -1))
+ sizeof(request.bytes), false) != MEMCACHED_SUCCESS) ||
+ (memcached_io_write(instance, key, key_length, true) == -1))
{
memcached_io_reset(instance);
return MEMCACHED_WRITE_FAILURE;
}
else
{
- rc= memcached_auto(ptr, "incr", master_key, master_key_length, key, key_length, offset, value);
+ rc= text_incr_decr(ptr, "incr", master_key, master_key_length, key, key_length, offset, value);
}
LIBMEMCACHED_MEMCACHED_INCREMENT_END();
LIBMEMCACHED_MEMCACHED_DECREMENT_START();
if (ptr->flags.binary_protocol)
+ {
rc= binary_incr_decr(ptr, PROTOCOL_BINARY_CMD_DECREMENT,
master_key, master_key_length, key, key_length,
(uint64_t)offset, 0, MEMCACHED_EXPIRATION_NOT_ADD,
value);
+ }
else
- rc= memcached_auto(ptr, "decr", master_key, master_key_length, key, key_length, offset, value);
+ {
+ rc= text_incr_decr(ptr, "decr", master_key, master_key_length, key, key_length, offset, value);
+ }
LIBMEMCACHED_MEMCACHED_DECREMENT_END();