3 memcached_return
memcached_delete(memcached_st
*ptr
, char *key
, size_t key_length
,
6 size_t send_length
, sent_length
;
8 char buffer
[MEMCACHED_DEFAULT_COMMAND_SIZE
];
9 unsigned int server_key
;
11 LIBMEMCACHED_MEMCACHED_DELETE_START();
13 server_key
= memcached_generate_hash(ptr
, key
, key_length
);
15 if ((rc
= memcached_connect(ptr
, server_key
)) != MEMCACHED_SUCCESS
)
20 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
21 "delete %.*s %llu\r\n", (int)key_length
, key
,
22 (unsigned long long)expiration
);
24 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
25 "delete %.*s\r\n", (int)key_length
, key
);
27 if (send_length
>= MEMCACHED_DEFAULT_COMMAND_SIZE
)
29 rc
= MEMCACHED_WRITE_FAILURE
;
33 sent_length
= memcached_io_write(ptr
, server_key
, buffer
, send_length
, 1);
35 if (sent_length
== -1 || sent_length
!= send_length
)
37 rc
= MEMCACHED_WRITE_FAILURE
;
41 rc
= memcached_response(ptr
, buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
, server_key
);
43 if (rc
== MEMCACHED_DELETED
)
44 rc
= MEMCACHED_SUCCESS
;
46 LIBMEMCACHED_MEMCACHED_DELETE_END();