技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 其他 --> 对TokyoTyrant的一个简单的patch,以支持列出所有的Key

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

浏览:1605次  出处信息

    有人在网上评价说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来玩了。

建议继续学习:

  1. 对TokyoTyrant的一个简单的patch,以支持列出所有的Key    (阅读:1600)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1