<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">I should have included disclaimers with the patch. Its intended for debugging. My cache has about 20K entries and it does not lock up the cache for any appreciable period.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>Steve, care to show me how to lock down the keys on their way out?<DIV><BR><DIV><DIV>On Feb 14, 2007, at 12:30 PM, Steven Grimm wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"> Be careful with that patch. No other client requests can be serviced while that loop is running (which may be a long time if your cache is large), but more critically, it doesn't lock down any of the cache entries. While the results are getting streamed out to the client, other clients can come in and change the cache, leading to garbage output; for example, if a long key gets overwritten by a short one before it's written, your list of "keys" will include the short key's terminating null and the start of its data.<BR> <BR> Also, your client will probably get confused if you have a key called "END" in your cache, but that's trivial to address.<BR> <BR> -Steve<BR> <BR> <BR> Randy Wigginton wrote: <BLOCKQUOTE cite="midCC4C99DE-BCB0-4297-863C-E749FD8ED018@nobugz.com" type="cite">... unless you want to add a few lines of code to your version of memcached. <DIV><BR class="khtml-block-placeholder"> </DIV> <DIV>Add this in, and send the command "keys <str>" and you will get a list of all keys containing that string,or just send "keys" and you'll get all.</DIV> <DIV><BR class="khtml-block-placeholder"> </DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">if</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> (strncmp(command, </SPAN></FONT><FONT class="Apple-style-span" color="#891315" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">"keys"</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">, </SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">4</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">) == </SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">0</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">) {</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">extern</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> item** getHashtable();</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">item **hashtable = getHashtable();</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">unsigned</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">long</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> i;</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">for</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> (i=</SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">0</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">; i<</SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">1</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"><<</SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">16</SPAN></FONT><FONT class="Apple-style-span" color="#236e25" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">/*HASHPOWER*/</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">; i++) {</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">item *it = hashtable[i];</SPAN></FONT></DIV> <DIV style="margin: 0px;"><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">int</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> outOfMem = </SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">0</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">;</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">while</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> (it && !outOfMem) {</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">char</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> *key = ITEM_key(it);</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">it = it->h_next;</SPAN></FONT></DIV> <DIV style="margin: 0px;"><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">if</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> (ntokens==</SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">3</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> && strstr(key, tokens[</SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">1</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">].value)==</SPAN></FONT><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">NULL</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">) {</SPAN></FONT></DIV> <DIV style="margin: 0px;"><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><FONT class="Apple-style-span" color="#760f50" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">continue</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">;</SPAN></FONT></DIV> <DIV style="margin: 0px;"><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">}</SPAN></FONT></DIV> <DIV style="margin: 0px;"><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">outOfMem = add_iov(c, key, strlen(key));</SPAN></FONT></DIV> <DIV style="margin: 0px;"><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">outOfMem += add_iov(c, </SPAN></FONT><FONT class="Apple-style-span" color="#891315" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">"\r\n"</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">, </SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">2</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">);</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">}</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">}</SPAN></FONT></DIV> <DIV style="margin: 0px;"><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"> </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">add_iov(c, </SPAN></FONT><FONT class="Apple-style-span" color="#891315" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">"END\r\n"</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">, </SPAN></FONT><FONT class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">5</SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">);</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><BR class="khtml-block-placeholder"> </DIV> <DIV style="margin: 0px;"><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">conn_set_state(c, conn_write);</SPAN></FONT></DIV> <DIV style="margin: 0px;"><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">c->write_and_go = conn_read;</SPAN></FONT></DIV> <DIV><SPAN class="Apple-tab-span" style="white-space: pre;"> </SPAN>}</DIV> <DIV><BR class="khtml-block-placeholder"> </DIV> <DIV><BR> <DIV> <DIV>On Feb 14, 2007, at 11:33 AM, Ask Bjørn Hansen wrote:</DIV> <BR class="Apple-interchange-newline"> <BLOCKQUOTE type="cite"> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> <DIV style="margin: 0px;">On Feb 14, 2007, at 5:51 AM, Jm lists wrote:</DIV> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> <BLOCKQUOTE type="cite"> <DIV style="margin: 0px;">Currently I want to use memcached as web's data cache.But I do need</DIV> <DIV style="margin: 0px;">the cached datas.So I want to dump datas to mysql periodicly.Can you</DIV> <DIV style="margin: 0px;">tell me how to dump all the datas stored in memcached?Thanks.</DIV> </BLOCKQUOTE> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> <DIV style="margin: 0px;">You can't.</DIV> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> <DIV style="margin: 0px;"><A href="http://www.socialtext.net/memcached/index.cgi?faq#can_i_iterate_the_items_of_the_memcached_server">http://www.socialtext.net/memcached/index.cgi?faq#can_i_iterate_the_items_of_the_memcached_server</A></DIV> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> <DIV style="margin: 0px;"><SPAN class="Apple-converted-space"> </SPAN>- ask</DIV> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> <DIV style="margin: 0px;">--<SPAN class="Apple-converted-space"> </SPAN></DIV> <DIV style="margin: 0px;"><A href="http://develooper.com">http://develooper.com</A>/ - <A href="http://askask.com">http://askask.com</A>/</DIV> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> <DIV style="margin: 0px; min-height: 14px;"><BR> </DIV> </BLOCKQUOTE> </DIV> <BR> </DIV> </BLOCKQUOTE> <BR> </BLOCKQUOTE></DIV><BR></DIV></DIV></BODY></HTML>