3 memcached_return
memcached_delete(memcached_st
*ptr
, char *key
, size_t key_length
,
7 size_t send_length
, sent_length
;
9 char buffer
[MEMCACHED_DEFAULT_COMMAND_SIZE
];
10 unsigned int server_key
;
12 LIBMEMCACHED_MEMCACHED_DELETE_START();
14 server_key
= memcached_generate_hash(ptr
, key
, key_length
);
16 if ((rc
= memcached_connect(ptr
, server_key
)) != MEMCACHED_SUCCESS
)
21 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
22 "delete %.*s %llu\r\n", (int)key_length
, key
,
23 (unsigned long long)expiration
);
25 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
26 "delete %.*s\r\n", (int)key_length
, key
);
28 if (send_length
>= MEMCACHED_DEFAULT_COMMAND_SIZE
)
30 rc
= MEMCACHED_WRITE_FAILURE
;
34 if ((ptr
->flags
& MEM_NO_BLOCK
))
39 if ((sent_length
= memcached_io_write(ptr
, server_key
, buffer
, send_length
, to_write
)) == -1)
41 memcached_quit_server(ptr
, server_key
);
42 rc
= MEMCACHED_WRITE_FAILURE
;
46 if ((ptr
->flags
& MEM_NO_BLOCK
))
48 rc
= MEMCACHED_SUCCESS
;
49 memcached_server_response_increment(ptr
, server_key
);
53 rc
= memcached_response(ptr
, buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
, server_key
);
54 if (rc
== MEMCACHED_DELETED
)
55 rc
= MEMCACHED_SUCCESS
;
58 LIBMEMCACHED_MEMCACHED_DELETE_END();