dump datas from memcached to database

Randy Wigginton krw at nobugz.com
Wed Feb 14 19:48:59 UTC 2007


... unless you want to add a few lines of code to your version of  
memcached.

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.

     if (strncmp(command, "keys", 4) == 0) {
         extern item** getHashtable();
         item **hashtable = getHashtable();
         unsigned long i;
         for (i=0; i<1<<16/*HASHPOWER*/; i++) {
             item *it = hashtable[i];
			int outOfMem = 0;
             while (it && !outOfMem) {
                 char *key = ITEM_key(it);
                 it = it->h_next;
				if (ntokens==3 && strstr(key, tokens[1].value)==NULL) {
					continue;
				}
				outOfMem = add_iov(c, key, strlen(key));
				outOfMem += add_iov(c, "\r\n", 2);
             }
         }
         add_iov(c, "END\r\n", 5);
		
		conn_set_state(c, conn_write);
		c->write_and_go = conn_read;
	}


On Feb 14, 2007, at 11:33 AM, Ask Bjørn Hansen wrote:

>
> On Feb 14, 2007, at 5:51 AM, Jm lists wrote:
>
>> Currently I want to use memcached as web's data cache.But I do need
>> the cached datas.So I want to dump datas to mysql periodicly.Can you
>> tell me how to dump all the datas stored in memcached?Thanks.
>
> You can't.
>
> http://www.socialtext.net/memcached/index.cgi? 
> faq#can_i_iterate_the_items_of_the_memcached_server
>
>
>  - ask
>
> -- 
> http://develooper.com/ - http://askask.com/
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20070214/e13405c2/attachment.htm


More information about the memcached mailing list