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_SUCCESS
)
14 rc
= MEMCACHED_SOME_ERRORS
;
16 memset(buffer
, 0, MEMCACHED_DEFAULT_COMMAND_SIZE
);
17 for (x
= 0; x
< ptr
->number_of_hosts
; x
++)
20 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
21 "flush_all %llu\r\n", (unsigned long long)expiration
);
23 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
26 if (send_length
>= MEMCACHED_DEFAULT_COMMAND_SIZE
)
27 return MEMCACHED_WRITE_FAILURE
;
29 sent_length
= memcached_io_write(ptr
, x
, buffer
, send_length
, 1);
31 if (sent_length
== -1 || sent_length
!= send_length
)
32 return MEMCACHED_WRITE_FAILURE
;
34 rc
= memcached_response(ptr
, buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
, x
);
36 if (rc
!= MEMCACHED_SUCCESS
)
37 rc
= MEMCACHED_SOME_ERRORS
;
40 LIBMEMCACHED_MEMCACHED_FLUSH_END();