@@ -72,13 +72,8 @@ cdef extern from "Export.h":
7272 uint32_t bytes
7373 cas_unique_t cas_unique
7474
75- ctypedef struct broadcast_result_t:
76- char * host
77- char ** lines
78- size_t* line_lens
79- size_t len
80-
8175 ctypedef enum message_result_type:
76+ MSG_LIBMC_INVALID
8277 MSG_EXISTS
8378 MSG_OK
8479 MSG_STORED
@@ -109,6 +104,13 @@ cdef extern from "Export.h":
109104 size_t key_len
110105 uint64_t value
111106
107+ ctypedef struct broadcast_result_t:
108+ char * host
109+ char ** lines
110+ size_t* line_lens
111+ size_t len
112+ message_result_type msg_type;
113+
112114
113115cdef extern from " Client.h" namespace " douban::mc" :
114116 cdef cppclass Client:
@@ -189,6 +191,8 @@ cdef extern from "Client.h" namespace "douban::mc":
189191 err_code_t version(broadcast_result_t** results, size_t* nHosts) nogil
190192 err_code_t quit() nogil
191193 err_code_t stats(broadcast_result_t** results, size_t* nHosts) nogil
194+ err_code_t flushAll(broadcast_result_t** results, size_t* nHosts) nogil
195+ void toggleFlushAllFeature(bool_t enabled)
192196 void destroyBroadcastResult() nogil
193197
194198 err_code_t incr(
@@ -952,6 +956,30 @@ cdef class PyClient:
952956 self ._imp.destroyBroadcastResult()
953957 return rv
954958
959+ def toggle_flush_all_feature (self , enabled ):
960+ self ._imp.toggleFlushAllFeature(enabled)
961+
962+ def flush_all (self ):
963+ self ._record_thread_ident()
964+ cdef broadcast_result_t* rst = NULL
965+ cdef size_t n = 0
966+ with nogil:
967+ self .last_error = self ._imp.flushAll(& rst, & n)
968+
969+ rv = []
970+ for i in range (n):
971+ if rst[i].msg_type == MSG_OK:
972+ rv.append(rst[i].host)
973+
974+ with nogil:
975+ self ._imp.destroyBroadcastResult()
976+ if self .last_error == RET_PROGRAMMING_ERR:
977+ raise RuntimeError (
978+ " Please call toggle_flush_all_feature(true) first "
979+ " to enable the flush_all feature."
980+ )
981+ return rv
982+
955983 def quit (self ):
956984 self ._record_thread_ident()
957985 with nogil:
0 commit comments