MEMCACHED_BAD_KEY_PROVIDED has been added as an error type. When libmemcached
[m6w6/libmemcached] / lib / memcached_flush.c
1 #include "common.h"
2
3 memcached_return memcached_flush(memcached_st *ptr, time_t expiration)
4 {
5 unsigned int x;
6 size_t send_length;
7 memcached_return rc;
8 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
9 LIBMEMCACHED_MEMCACHED_FLUSH_START();
10
11 if (ptr->number_of_hosts == 0)
12 return MEMCACHED_NO_SERVERS;
13
14 for (x= 0; x < ptr->number_of_hosts; x++)
15 {
16 if (expiration)
17 send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
18 "flush_all %llu\r\n", (unsigned long long)expiration);
19 else
20 send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
21 "flush_all\r\n");
22
23 rc= memcached_do(&ptr->hosts[x], buffer, send_length, 1);
24
25 if (rc == MEMCACHED_SUCCESS)
26 (void)memcached_response(&ptr->hosts[x], buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
27 }
28
29 LIBMEMCACHED_MEMCACHED_FLUSH_END();
30 return MEMCACHED_SUCCESS;
31 }