3 memcached_return
memcached_delete(memcached_st
*ptr
, char *key
, size_t key_length
,
6 return memcached_delete_by_key(ptr
, key
, key_length
,
7 key
, key_length
, expiration
);
10 memcached_return
memcached_delete_by_key(memcached_st
*ptr
,
11 char *master_key
, size_t master_key_length
,
12 char *key
, size_t key_length
,
18 char buffer
[MEMCACHED_DEFAULT_COMMAND_SIZE
];
19 unsigned int server_key
;
21 LIBMEMCACHED_MEMCACHED_DELETE_START();
23 unlikely (key_length
== 0)
24 return MEMCACHED_NO_KEY_PROVIDED
;
26 unlikely (ptr
->hosts
== NULL
|| ptr
->number_of_hosts
== 0)
27 return MEMCACHED_NO_SERVERS
;
29 server_key
= memcached_generate_hash(ptr
, master_key
, master_key_length
);
32 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
33 "delete %.*s %llu\r\n", (int)key_length
, key
,
34 (unsigned long long)expiration
);
36 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
37 "delete %.*s\r\n", (int)key_length
, key
);
39 if (send_length
>= MEMCACHED_DEFAULT_COMMAND_SIZE
)
41 rc
= MEMCACHED_WRITE_FAILURE
;
45 to_write
= (ptr
->flags
& MEM_BUFFER_REQUESTS
) ? 0 : 1;
47 rc
= memcached_do(&ptr
->hosts
[server_key
], buffer
, send_length
, to_write
);
48 if (rc
!= MEMCACHED_SUCCESS
)
51 if ((ptr
->flags
& MEM_BUFFER_REQUESTS
))
53 rc
= MEMCACHED_BUFFERED
;
57 rc
= memcached_response(&ptr
->hosts
[server_key
], buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
, NULL
);
58 if (rc
== MEMCACHED_DELETED
)
59 rc
= MEMCACHED_SUCCESS
;
63 LIBMEMCACHED_MEMCACHED_DELETE_END();