对 TokyoTyrant的一个简单的patch,以支持列出所有的Key

有人在网上评价说Redis、mongodb等Key-value对的数据库,说redis特别牛,能支持列出所有的 key;
其实tokyotyrant也是可以的呀,因为我看他底层持tcmdb,tchdb等都是支持遍历所有Key的,于是小小地做了一个改动,以支持列出的 tokyotyrant的所有Key.
代码放在http://github.com/xurenlu/mc_list_patch_4_tokyotyrant上了。
用法:
1.启动ttserver:
ttserver db.tch
3.telnet上去,试试set命令:

telnet localhost 1978
Trying 127.0.0.1…
Connected to localhost.localdomain.
Escape character is ‘^]’.
set kw2 1 1 3
123
STORED
list
LIST 9
kw
kw2
END
看这里,已经支持list命令了。
2 再用php客户端来连接:我还没有去用c写php的memcached客户端,就从网上找了一个php做的类,在git目录里有:

include “memcache.class.php”;
$hosts = array(’127.0.0.1:1978′);
$mc = &new MemCachedClient($hosts);
var_dump($mc->listkeys());
关于安装:
1.tokyotyrant基于tokyocabinet,需要先安装 tokyocabinet,请在http://github.com/xurenlu/mc_list_patch_4_tokyotyrant /downloads 下载.

~/download@aragorn $ wget http://cloud.github.com/downloads/xurenlu/mc_list_patch_4_tokyotyrant/tokyocabinet-1.4.41.tar.gz
~/download@aragorn $ tar -xzf tokyocabinet-1.4.41.tar.gz
~/download@aragorn $ cd tokyocabinet-1.4.41
~/download/tokyocabinet-1.4.41@aragorn $ ./configure
….省却若干输出…
~/download/tokyocabinet-1.4.41@aragorn $ make && make install
接下来,请先下载tokyotyrant 1.1.37,可以在http://github.com/xurenlu/mc_list_patch_4_tokyotyrant /downloads 这里下载.
下载下来后,解压、patch:

~/download@aragorn $ wget http://cloud.github.com/downloads/xurenlu/mc_list_patch_4_tokyotyrant/tokyotyrant-1.1.37.tar.gz
~/download@aragorn $ tar -xzf tokyotyrant-1.1.37.tar.gz
~/download@aragorn $ patch -p0 < mc_list.patch
patching file tokyotyrant-1.1.37/ttserver.c
然后编译tokyotyrant:

~/download/@aragorn $cd tokyotyrant-1.1.37
~/download/tokyotyrant-1.1.37/@aragorn $ ./configure
…..若干输出,略去..
~/download/tokyotyrant-1.1.37/@aragorn $ make && sudo make install
接下来就可以启动ttserver来玩了。

发布了31 篇原创文章 · 获赞 11 · 访问量 23万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章