對 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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章