time_t expiration)
{
char to_write;
- size_t send_length, sent_length;
+ size_t send_length;
memcached_return rc;
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
unsigned int server_key;
LIBMEMCACHED_MEMCACHED_DELETE_START();
+ if (key_length == 0)
+ return MEMCACHED_NO_KEY_PROVIDED;
+
if (ptr->hosts == NULL || ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
server_key= memcached_generate_hash(ptr, key, key_length);
- if ((rc= memcached_connect(ptr, server_key)) != MEMCACHED_SUCCESS)
- return rc;
-
-
if (expiration)
send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
"delete %.*s %llu\r\n", (int)key_length, key,
else
to_write= 1;
- if ((sent_length= memcached_io_write(ptr, server_key, buffer, send_length, to_write)) == -1)
- {
- memcached_quit_server(ptr, server_key);
- rc= MEMCACHED_WRITE_FAILURE;
+ rc= memcached_do(ptr, server_key, buffer, send_length, to_write);
+ if (rc != MEMCACHED_SUCCESS)
goto error;
- }
if ((ptr->flags & MEM_NO_BLOCK))
{
rc= MEMCACHED_SUCCESS;
}
- LIBMEMCACHED_MEMCACHED_DELETE_END();
-
error:
+ LIBMEMCACHED_MEMCACHED_DELETE_END();
return rc;
}