- char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
- int send_length;
-
- if (expiration)
- {
- if ((instance->major_version == 1 and
- instance->minor_version > 2) or
- instance->major_version > 1)
- {
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
- memcached_literal_param("Memcached server version does not allow expiration of deleted items"));
- }
- else
- {
- /* ensure that we are connected, otherwise we might bump the
- * command counter before connection */
- memcached_return_t rc;
- if ((rc= memcached_connect(instance)) != MEMCACHED_SUCCESS)
- {
- WATCHPOINT_ERROR(rc);
- return rc;
- }
-
- if (instance->minor_version == 0)
- {
- if (reply == false or flush == false)
- {
- /* We might get out of sync with the server if we send this command
- * to a server newer than 1.2.x.. enable reply and buffered mode.
- */
- flush= true;
- if (reply == false)
- {
- memcached_server_response_increment(instance);
- }
- reply= true;
- }
- }
-
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "delete %.*s%.*s %u%s\r\n",
- memcached_print_array(ptr->_namespace),
- (int) key_length, key,
- (uint32_t)expiration,
- reply ? "" : " noreply");
- }
- }
- else
- {
- send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
- "delete %.*s%.*s%s\r\n",
- memcached_print_array(ptr->_namespace),
- (int)key_length, key,
- reply ? "" : " noreply");
- }
-
- if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0)
- {
- return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT,
- memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
- }
-
- if (ptr->flags.use_udp and flush == false)
- {
- if (send_length > MAX_UDP_DATAGRAM_LENGTH - UDP_DATAGRAM_HEADER_LENGTH)
- {
- return MEMCACHED_WRITE_FAILURE;
- }
-
- if (send_length +instance->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH)
- {
- memcached_io_write(instance, NULL, 0, true);
- }
- }
+ libmemcached_io_vector_st vector[]=
+ {
+ { NULL, 0 },
+ { memcached_literal_param("delete ") },
+ { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) },
+ { key, key_length },
+ { " noreply", reply ? 0 : memcached_literal_param_size(" noreply") },
+ { memcached_literal_param("\r\n") }
+ };