3 memcached_return
memcached_flush(memcached_st
*ptr
, time_t expiration
)
6 size_t send_length
, sent_length
;
8 char buffer
[MEMCACHED_DEFAULT_COMMAND_SIZE
];
9 LIBMEMCACHED_MEMCACHED_FLUSH_START();
11 rc
= memcached_connect(ptr
, 0);
13 if (rc
== MEMCACHED_NO_SERVERS
)
16 if (rc
!= MEMCACHED_SUCCESS
)
17 rc
= MEMCACHED_SOME_ERRORS
;
19 memset(buffer
, 0, MEMCACHED_DEFAULT_COMMAND_SIZE
);
20 for (x
= 0; x
< ptr
->number_of_hosts
; x
++)
23 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
24 "flush_all %llu\r\n", (unsigned long long)expiration
);
26 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
29 if (send_length
>= MEMCACHED_DEFAULT_COMMAND_SIZE
)
30 return MEMCACHED_WRITE_FAILURE
;
32 sent_length
= memcached_io_write(ptr
, x
, buffer
, send_length
, 1);
34 if (sent_length
== -1 || sent_length
!= send_length
)
35 return MEMCACHED_WRITE_FAILURE
;
37 rc
= memcached_response(ptr
, buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
, x
);
39 if (rc
!= MEMCACHED_SUCCESS
)
40 rc
= MEMCACHED_SOME_ERRORS
;
43 LIBMEMCACHED_MEMCACHED_FLUSH_END();