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
];
10 rc
= memcached_connect(ptr
);
12 if (rc
!= MEMCACHED_SUCCESS
)
13 rc
= MEMCACHED_SOME_ERRORS
;
15 memset(buffer
, 0, MEMCACHED_DEFAULT_COMMAND_SIZE
);
16 for (x
= 0; x
< ptr
->number_of_hosts
; x
++)
19 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
20 "flush_all %llu\r\n", (unsigned long long)expiration
);
22 send_length
= snprintf(buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
,
25 if (send_length
>= MEMCACHED_DEFAULT_COMMAND_SIZE
)
26 return MEMCACHED_WRITE_FAILURE
;
28 sent_length
= write(ptr
->hosts
[x
].fd
, buffer
, send_length
);
30 if (sent_length
== -1 || sent_length
!= send_length
)
31 return MEMCACHED_WRITE_FAILURE
;
33 rc
= memcached_response(ptr
, buffer
, MEMCACHED_DEFAULT_COMMAND_SIZE
, x
);
35 if (rc
!= MEMCACHED_SUCCESS
)
36 rc
= MEMCACHED_SOME_ERRORS
;