heroku-tokyotyrant 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +504 -0
- data/README.rdoc +231 -0
- data/Rakefile +72 -0
- data/benchmarks/balancer.rb +101 -0
- data/benchmarks/bulk_db.rb +74 -0
- data/benchmarks/bulk_table.rb +87 -0
- data/benchmarks/db.rb +114 -0
- data/benchmarks/table.rb +161 -0
- data/ext/extconf.rb +43 -0
- data/ext/tokyo/bin/tcamgr +0 -0
- data/ext/tokyo/bin/tcamttest +0 -0
- data/ext/tokyo/bin/tcatest +0 -0
- data/ext/tokyo/bin/tcbmgr +0 -0
- data/ext/tokyo/bin/tcbmttest +0 -0
- data/ext/tokyo/bin/tcbtest +0 -0
- data/ext/tokyo/bin/tcfmgr +0 -0
- data/ext/tokyo/bin/tcfmttest +0 -0
- data/ext/tokyo/bin/tcftest +0 -0
- data/ext/tokyo/bin/tchmgr +0 -0
- data/ext/tokyo/bin/tchmttest +0 -0
- data/ext/tokyo/bin/tchtest +0 -0
- data/ext/tokyo/bin/tcrmgr +0 -0
- data/ext/tokyo/bin/tcrmttest +0 -0
- data/ext/tokyo/bin/tcrtest +0 -0
- data/ext/tokyo/bin/tctmgr +0 -0
- data/ext/tokyo/bin/tctmttest +0 -0
- data/ext/tokyo/bin/tcttest +0 -0
- data/ext/tokyo/bin/tcucodec +0 -0
- data/ext/tokyo/bin/tcumttest +0 -0
- data/ext/tokyo/bin/tcutest +0 -0
- data/ext/tokyo/bin/ttserver +0 -0
- data/ext/tokyo/bin/ttulmgr +0 -0
- data/ext/tokyo/bin/ttultest +0 -0
- data/ext/tokyo/include/tcadb.h +548 -0
- data/ext/tokyo/include/tcbdb.h +1101 -0
- data/ext/tokyo/include/tcfdb.h +858 -0
- data/ext/tokyo/include/tchdb.h +871 -0
- data/ext/tokyo/include/tcrdb.h +801 -0
- data/ext/tokyo/include/tctdb.h +1086 -0
- data/ext/tokyo/include/tculog.h +392 -0
- data/ext/tokyo/include/tcutil.h +4184 -0
- data/ext/tokyo/include/ttutil.h +494 -0
- data/ext/tokyo/lib/libtokyocabinet.9.4.0.dylib +0 -0
- data/ext/tokyo/lib/libtokyocabinet.9.dylib +0 -0
- data/ext/tokyo/lib/libtokyocabinet.a +0 -0
- data/ext/tokyo/lib/libtokyocabinet.dylib +0 -0
- data/ext/tokyo/lib/libtokyotyrant.3.22.0.dylib +0 -0
- data/ext/tokyo/lib/libtokyotyrant.3.dylib +0 -0
- data/ext/tokyo/lib/libtokyotyrant.a +0 -0
- data/ext/tokyo/lib/libtokyotyrant.dylib +0 -0
- data/ext/tokyo/lib/pkgconfig/tokyocabinet.pc +14 -0
- data/ext/tokyo/lib/pkgconfig/tokyotyrant.pc +14 -0
- data/ext/tokyo/lib/ttskeldir.bundle +0 -0
- data/ext/tokyo/lib/ttskelmock.bundle +0 -0
- data/ext/tokyo/lib/ttskelnull.bundle +0 -0
- data/ext/tokyo/lib/ttskelproxy.bundle +0 -0
- data/ext/tokyo/libexec/tcawmgr.cgi +0 -0
- data/ext/tokyo/sbin/ttservctl +163 -0
- data/ext/tokyo/share/man/man1/tcamgr.1 +97 -0
- data/ext/tokyo/share/man/man1/tcamttest.1 +35 -0
- data/ext/tokyo/share/man/man1/tcatest.1 +55 -0
- data/ext/tokyo/share/man/man1/tcbmgr.1 +125 -0
- data/ext/tokyo/share/man/man1/tcbmttest.1 +81 -0
- data/ext/tokyo/share/man/man1/tcbtest.1 +107 -0
- data/ext/tokyo/share/man/man1/tcfmgr.1 +98 -0
- data/ext/tokyo/share/man/man1/tcfmttest.1 +62 -0
- data/ext/tokyo/share/man/man1/tcftest.1 +73 -0
- data/ext/tokyo/share/man/man1/tchmgr.1 +110 -0
- data/ext/tokyo/share/man/man1/tchmttest.1 +85 -0
- data/ext/tokyo/share/man/man1/tchtest.1 +95 -0
- data/ext/tokyo/share/man/man1/tcrmgr.1 +164 -0
- data/ext/tokyo/share/man/man1/tcrmttest.1 +55 -0
- data/ext/tokyo/share/man/man1/tcrtest.1 +89 -0
- data/ext/tokyo/share/man/man1/tctmgr.1 +140 -0
- data/ext/tokyo/share/man/man1/tctmttest.1 +92 -0
- data/ext/tokyo/share/man/man1/tcttest.1 +105 -0
- data/ext/tokyo/share/man/man1/tcucodec.1 +162 -0
- data/ext/tokyo/share/man/man1/tcumttest.1 +41 -0
- data/ext/tokyo/share/man/man1/tcutest.1 +81 -0
- data/ext/tokyo/share/man/man1/ttserver.1 +84 -0
- data/ext/tokyo/share/man/man1/ttulmgr.1 +40 -0
- data/ext/tokyo/share/man/man1/ttultest.1 +16 -0
- data/ext/tokyo/share/man/man3/tcadb.3 +676 -0
- data/ext/tokyo/share/man/man3/tcbdb.3 +1355 -0
- data/ext/tokyo/share/man/man3/tcfdb.3 +975 -0
- data/ext/tokyo/share/man/man3/tchdb.3 +898 -0
- data/ext/tokyo/share/man/man3/tclist.3 +1 -0
- data/ext/tokyo/share/man/man3/tcmap.3 +1 -0
- data/ext/tokyo/share/man/man3/tcmdb.3 +1 -0
- data/ext/tokyo/share/man/man3/tcmpool.3 +1 -0
- data/ext/tokyo/share/man/man3/tcrdb.3 +1309 -0
- data/ext/tokyo/share/man/man3/tctdb.3 +1110 -0
- data/ext/tokyo/share/man/man3/tctree.3 +1 -0
- data/ext/tokyo/share/man/man3/tculog.3 +15 -0
- data/ext/tokyo/share/man/man3/tcutil.3 +4518 -0
- data/ext/tokyo/share/man/man3/tcxstr.3 +1 -0
- data/ext/tokyo/share/man/man3/tokyocabinet.3 +132 -0
- data/ext/tokyo/share/man/man3/ttutil.3 +14 -0
- data/ext/tokyo/share/man/man8/ttservctl.8 +37 -0
- data/ext/tokyo/share/tokyocabinet/COPYING +504 -0
- data/ext/tokyo/share/tokyocabinet/ChangeLog +1252 -0
- data/ext/tokyo/share/tokyocabinet/THANKS +12 -0
- data/ext/tokyo/share/tokyocabinet/doc/benchmark.pdf +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/common.css +211 -0
- data/ext/tokyo/share/tokyocabinet/doc/icon16.png +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/index.html +156 -0
- data/ext/tokyo/share/tokyocabinet/doc/index.ja.html +197 -0
- data/ext/tokyo/share/tokyocabinet/doc/logo-ja.png +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/logo.png +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/spex-en.html +7145 -0
- data/ext/tokyo/share/tokyocabinet/doc/spex-ja.html +7476 -0
- data/ext/tokyo/share/tokyocabinet/doc/tokyoproducts.pdf +0 -0
- data/ext/tokyo/share/tokyocabinet/doc/tokyoproducts.ppt +0 -0
- data/ext/tokyo/share/tokyotyrant/COPYING +504 -0
- data/ext/tokyo/share/tokyotyrant/ChangeLog +578 -0
- data/ext/tokyo/share/tokyotyrant/THANKS +15 -0
- data/ext/tokyo/share/tokyotyrant/doc/common.css +211 -0
- data/ext/tokyo/share/tokyotyrant/doc/index.html +79 -0
- data/ext/tokyo/share/tokyotyrant/doc/spex.html +2264 -0
- data/ext/tokyo/share/tokyotyrant/ext/mapreduce.lua +57 -0
- data/ext/tokyo/share/tokyotyrant/ext/queue.lua +55 -0
- data/ext/tokyo/share/tokyotyrant/ext/senatus.lua +532 -0
- data/ext/tokyo/share/tokyotyrant/ext/usherette.lua +438 -0
- data/ext/tokyo_tyrant.c +147 -0
- data/ext/tokyo_tyrant.h +48 -0
- data/ext/tokyo_tyrant_db.c +227 -0
- data/ext/tokyo_tyrant_db.h +8 -0
- data/ext/tokyo_tyrant_module.c +453 -0
- data/ext/tokyo_tyrant_module.h +10 -0
- data/ext/tokyo_tyrant_query.c +226 -0
- data/ext/tokyo_tyrant_query.h +9 -0
- data/ext/tokyo_tyrant_table.c +319 -0
- data/ext/tokyo_tyrant_table.h +8 -0
- data/ext/tokyocabinet-1.4.41/COPYING +504 -0
- data/ext/tokyocabinet-1.4.41/ChangeLog +1252 -0
- data/ext/tokyocabinet-1.4.41/Makefile.in +825 -0
- data/ext/tokyocabinet-1.4.41/README +38 -0
- data/ext/tokyocabinet-1.4.41/THANKS +12 -0
- data/ext/tokyocabinet-1.4.41/bros/Makefile +133 -0
- data/ext/tokyocabinet-1.4.41/bros/bdbtest.c +438 -0
- data/ext/tokyocabinet-1.4.41/bros/cdbtest.c +219 -0
- data/ext/tokyocabinet-1.4.41/bros/cmpsqltctest.c +186 -0
- data/ext/tokyocabinet-1.4.41/bros/gdbmtest.c +216 -0
- data/ext/tokyocabinet-1.4.41/bros/mapreporter +72 -0
- data/ext/tokyocabinet-1.4.41/bros/maptest.cc +677 -0
- data/ext/tokyocabinet-1.4.41/bros/ndbmtest.c +204 -0
- data/ext/tokyocabinet-1.4.41/bros/qdbmtest.c +375 -0
- data/ext/tokyocabinet-1.4.41/bros/reporter +141 -0
- data/ext/tokyocabinet-1.4.41/bros/result.xls +0 -0
- data/ext/tokyocabinet-1.4.41/bros/sdbmtest.c +204 -0
- data/ext/tokyocabinet-1.4.41/bros/sqltest.c +404 -0
- data/ext/tokyocabinet-1.4.41/bros/tctest.c +748 -0
- data/ext/tokyocabinet-1.4.41/bros/tdbtest.c +205 -0
- data/ext/tokyocabinet-1.4.41/configure +7402 -0
- data/ext/tokyocabinet-1.4.41/configure.in +362 -0
- data/ext/tokyocabinet-1.4.41/doc/benchmark.pdf +0 -0
- data/ext/tokyocabinet-1.4.41/doc/common.css +211 -0
- data/ext/tokyocabinet-1.4.41/doc/icon16.png +0 -0
- data/ext/tokyocabinet-1.4.41/doc/index.html +156 -0
- data/ext/tokyocabinet-1.4.41/doc/index.ja.html +197 -0
- data/ext/tokyocabinet-1.4.41/doc/logo-ja.png +0 -0
- data/ext/tokyocabinet-1.4.41/doc/logo.png +0 -0
- data/ext/tokyocabinet-1.4.41/doc/spex-en.html +7145 -0
- data/ext/tokyocabinet-1.4.41/doc/spex-ja.html +7476 -0
- data/ext/tokyocabinet-1.4.41/doc/tokyoproducts.pdf +0 -0
- data/ext/tokyocabinet-1.4.41/doc/tokyoproducts.ppt +0 -0
- data/ext/tokyocabinet-1.4.41/example/Makefile +113 -0
- data/ext/tokyocabinet-1.4.41/example/tcadbex.c +55 -0
- data/ext/tokyocabinet-1.4.41/example/tcbdbex.c +64 -0
- data/ext/tokyocabinet-1.4.41/example/tcfdbex.c +60 -0
- data/ext/tokyocabinet-1.4.41/example/tchdbex.c +60 -0
- data/ext/tokyocabinet-1.4.41/example/tctchat.c +97 -0
- data/ext/tokyocabinet-1.4.41/example/tctchat.tmpl +141 -0
- data/ext/tokyocabinet-1.4.41/example/tctdbex.c +85 -0
- data/ext/tokyocabinet-1.4.41/example/tctsearch.c +95 -0
- data/ext/tokyocabinet-1.4.41/example/tctsearch.tmpl +122 -0
- data/ext/tokyocabinet-1.4.41/example/tcutilex.c +77 -0
- data/ext/tokyocabinet-1.4.41/f.tsv +2 -0
- data/ext/tokyocabinet-1.4.41/lab/calccomp +118 -0
- data/ext/tokyocabinet-1.4.41/lab/datechange +56 -0
- data/ext/tokyocabinet-1.4.41/lab/diffcheck +45 -0
- data/ext/tokyocabinet-1.4.41/lab/htmltotsv +102 -0
- data/ext/tokyocabinet-1.4.41/lab/magic +19 -0
- data/ext/tokyocabinet-1.4.41/lab/printenv.cgi +27 -0
- data/ext/tokyocabinet-1.4.41/lab/stepcount +26 -0
- data/ext/tokyocabinet-1.4.41/lab/stopwatch +61 -0
- data/ext/tokyocabinet-1.4.41/lab/tabcheck +43 -0
- data/ext/tokyocabinet-1.4.41/lab/wgettsv +239 -0
- data/ext/tokyocabinet-1.4.41/lab/widthcheck +57 -0
- data/ext/tokyocabinet-1.4.41/man/htmltoman +104 -0
- data/ext/tokyocabinet-1.4.41/man/tcadb.3 +676 -0
- data/ext/tokyocabinet-1.4.41/man/tcamgr.1 +97 -0
- data/ext/tokyocabinet-1.4.41/man/tcamttest.1 +35 -0
- data/ext/tokyocabinet-1.4.41/man/tcatest.1 +55 -0
- data/ext/tokyocabinet-1.4.41/man/tcbdb.3 +1355 -0
- data/ext/tokyocabinet-1.4.41/man/tcbmgr.1 +125 -0
- data/ext/tokyocabinet-1.4.41/man/tcbmttest.1 +81 -0
- data/ext/tokyocabinet-1.4.41/man/tcbtest.1 +107 -0
- data/ext/tokyocabinet-1.4.41/man/tcfdb.3 +975 -0
- data/ext/tokyocabinet-1.4.41/man/tcfmgr.1 +98 -0
- data/ext/tokyocabinet-1.4.41/man/tcfmttest.1 +62 -0
- data/ext/tokyocabinet-1.4.41/man/tcftest.1 +73 -0
- data/ext/tokyocabinet-1.4.41/man/tchdb.3 +898 -0
- data/ext/tokyocabinet-1.4.41/man/tchmgr.1 +110 -0
- data/ext/tokyocabinet-1.4.41/man/tchmttest.1 +85 -0
- data/ext/tokyocabinet-1.4.41/man/tchtest.1 +95 -0
- data/ext/tokyocabinet-1.4.41/man/tclist.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tcmap.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tcmdb.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tcmpool.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tctdb.3 +1110 -0
- data/ext/tokyocabinet-1.4.41/man/tctmgr.1 +140 -0
- data/ext/tokyocabinet-1.4.41/man/tctmttest.1 +92 -0
- data/ext/tokyocabinet-1.4.41/man/tctree.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tcttest.1 +105 -0
- data/ext/tokyocabinet-1.4.41/man/tcucodec.1 +162 -0
- data/ext/tokyocabinet-1.4.41/man/tcumttest.1 +41 -0
- data/ext/tokyocabinet-1.4.41/man/tcutest.1 +81 -0
- data/ext/tokyocabinet-1.4.41/man/tcutil.3 +4518 -0
- data/ext/tokyocabinet-1.4.41/man/tcxstr.3 +1 -0
- data/ext/tokyocabinet-1.4.41/man/tokyocabinet.3 +132 -0
- data/ext/tokyocabinet-1.4.41/md5.c +381 -0
- data/ext/tokyocabinet-1.4.41/md5.h +101 -0
- data/ext/tokyocabinet-1.4.41/myconf.c +493 -0
- data/ext/tokyocabinet-1.4.41/myconf.h +549 -0
- data/ext/tokyocabinet-1.4.41/tcadb.c +4339 -0
- data/ext/tokyocabinet-1.4.41/tcadb.h +548 -0
- data/ext/tokyocabinet-1.4.41/tcamgr.c +1019 -0
- data/ext/tokyocabinet-1.4.41/tcamttest.c +542 -0
- data/ext/tokyocabinet-1.4.41/tcatest.c +1845 -0
- data/ext/tokyocabinet-1.4.41/tcawmgr.c +482 -0
- data/ext/tokyocabinet-1.4.41/tcbdb.c +4180 -0
- data/ext/tokyocabinet-1.4.41/tcbdb.h +1101 -0
- data/ext/tokyocabinet-1.4.41/tcbmgr.c +1012 -0
- data/ext/tokyocabinet-1.4.41/tcbmttest.c +1810 -0
- data/ext/tokyocabinet-1.4.41/tcbtest.c +2586 -0
- data/ext/tokyocabinet-1.4.41/tcfdb.c +2746 -0
- data/ext/tokyocabinet-1.4.41/tcfdb.h +858 -0
- data/ext/tokyocabinet-1.4.41/tcfmgr.c +786 -0
- data/ext/tokyocabinet-1.4.41/tcfmttest.c +1220 -0
- data/ext/tokyocabinet-1.4.41/tcftest.c +1695 -0
- data/ext/tokyocabinet-1.4.41/tchdb.c +5153 -0
- data/ext/tokyocabinet-1.4.41/tchdb.h +871 -0
- data/ext/tokyocabinet-1.4.41/tchmgr.c +842 -0
- data/ext/tokyocabinet-1.4.41/tchmttest.c +1757 -0
- data/ext/tokyocabinet-1.4.41/tchtest.c +2129 -0
- data/ext/tokyocabinet-1.4.41/tctdb.c +6199 -0
- data/ext/tokyocabinet-1.4.41/tctdb.h +1086 -0
- data/ext/tokyocabinet-1.4.41/tctmgr.c +1241 -0
- data/ext/tokyocabinet-1.4.41/tctmttest.c +1563 -0
- data/ext/tokyocabinet-1.4.41/tcttest.c +2062 -0
- data/ext/tokyocabinet-1.4.41/tcucodec.c +1357 -0
- data/ext/tokyocabinet-1.4.41/tcumttest.c +578 -0
- data/ext/tokyocabinet-1.4.41/tcutest.c +1875 -0
- data/ext/tokyocabinet-1.4.41/tcutil.c +10528 -0
- data/ext/tokyocabinet-1.4.41/tcutil.h +4184 -0
- data/ext/tokyocabinet-1.4.41/tokyocabinet.idl +336 -0
- data/ext/tokyocabinet-1.4.41/tokyocabinet.pc.in +14 -0
- data/ext/tokyotyrant-1.1.39/COPYING +504 -0
- data/ext/tokyotyrant-1.1.39/ChangeLog +578 -0
- data/ext/tokyotyrant-1.1.39/Makefile.in +365 -0
- data/ext/tokyotyrant-1.1.39/README +38 -0
- data/ext/tokyotyrant-1.1.39/THANKS +15 -0
- data/ext/tokyotyrant-1.1.39/configure +6979 -0
- data/ext/tokyotyrant-1.1.39/configure.in +300 -0
- data/ext/tokyotyrant-1.1.39/doc/common.css +211 -0
- data/ext/tokyotyrant-1.1.39/doc/index.html +79 -0
- data/ext/tokyotyrant-1.1.39/doc/spex.html +2264 -0
- data/ext/tokyotyrant-1.1.39/example/Makefile +68 -0
- data/ext/tokyotyrant-1.1.39/example/httptest.pl +88 -0
- data/ext/tokyotyrant-1.1.39/example/mcftest.pl +39 -0
- data/ext/tokyotyrant-1.1.39/example/mctest.pl +43 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbex +0 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbex.c +49 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbex.o +0 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbtblex +0 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbtblex.c +79 -0
- data/ext/tokyotyrant-1.1.39/example/tcrdbtblex.o +0 -0
- data/ext/tokyotyrant-1.1.39/ext/mapreduce.lua +57 -0
- data/ext/tokyotyrant-1.1.39/ext/queue.lua +55 -0
- data/ext/tokyotyrant-1.1.39/ext/senatus.lua +532 -0
- data/ext/tokyotyrant-1.1.39/ext/usherette.lua +438 -0
- data/ext/tokyotyrant-1.1.39/lab/datechange +56 -0
- data/ext/tokyotyrant-1.1.39/lab/diffcheck +45 -0
- data/ext/tokyotyrant-1.1.39/lab/fibonacci.lua +20 -0
- data/ext/tokyotyrant-1.1.39/lab/footprint.lua +67 -0
- data/ext/tokyotyrant-1.1.39/lab/highlow.lua +88 -0
- data/ext/tokyotyrant-1.1.39/lab/killdualmaster +12 -0
- data/ext/tokyotyrant-1.1.39/lab/rundualmaster +38 -0
- data/ext/tokyotyrant-1.1.39/lab/stepcount +26 -0
- data/ext/tokyotyrant-1.1.39/lab/tabcheck +43 -0
- data/ext/tokyotyrant-1.1.39/lab/ushrtregister.pl +55 -0
- data/ext/tokyotyrant-1.1.39/lab/widthcheck +57 -0
- data/ext/tokyotyrant-1.1.39/man/htmltoman +100 -0
- data/ext/tokyotyrant-1.1.39/man/tcrdb.3 +1309 -0
- data/ext/tokyotyrant-1.1.39/man/tcrmgr.1 +164 -0
- data/ext/tokyotyrant-1.1.39/man/tcrmttest.1 +55 -0
- data/ext/tokyotyrant-1.1.39/man/tcrtest.1 +89 -0
- data/ext/tokyotyrant-1.1.39/man/tculog.3 +15 -0
- data/ext/tokyotyrant-1.1.39/man/ttservctl.8 +37 -0
- data/ext/tokyotyrant-1.1.39/man/ttserver.1 +84 -0
- data/ext/tokyotyrant-1.1.39/man/ttulmgr.1 +40 -0
- data/ext/tokyotyrant-1.1.39/man/ttultest.1 +16 -0
- data/ext/tokyotyrant-1.1.39/man/ttutil.3 +14 -0
- data/ext/tokyotyrant-1.1.39/myconf.c +169 -0
- data/ext/tokyotyrant-1.1.39/myconf.h +408 -0
- data/ext/tokyotyrant-1.1.39/scrext.c +2394 -0
- data/ext/tokyotyrant-1.1.39/scrext.h +96 -0
- data/ext/tokyotyrant-1.1.39/tcrdb.c +2637 -0
- data/ext/tokyotyrant-1.1.39/tcrdb.h +801 -0
- data/ext/tokyotyrant-1.1.39/tcrmgr.c +1559 -0
- data/ext/tokyotyrant-1.1.39/tcrmttest.c +915 -0
- data/ext/tokyotyrant-1.1.39/tcrtest.c +1542 -0
- data/ext/tokyotyrant-1.1.39/tculog.c +1211 -0
- data/ext/tokyotyrant-1.1.39/tculog.h +392 -0
- data/ext/tokyotyrant-1.1.39/tokyotyrant.idl +143 -0
- data/ext/tokyotyrant-1.1.39/tokyotyrant.pc.in +14 -0
- data/ext/tokyotyrant-1.1.39/ttservctl +163 -0
- data/ext/tokyotyrant-1.1.39/ttserver.c +3583 -0
- data/ext/tokyotyrant-1.1.39/ttskeldir.c +141 -0
- data/ext/tokyotyrant-1.1.39/ttskelmock.c +64 -0
- data/ext/tokyotyrant-1.1.39/ttskelnull.c +79 -0
- data/ext/tokyotyrant-1.1.39/ttskelproxy.c +74 -0
- data/ext/tokyotyrant-1.1.39/ttulmgr.c +266 -0
- data/ext/tokyotyrant-1.1.39/ttultest.c +371 -0
- data/ext/tokyotyrant-1.1.39/ttutil.c +1510 -0
- data/ext/tokyotyrant-1.1.39/ttutil.h +494 -0
- data/lib/tokyo_tyrant/balancer.rb +189 -0
- data/spec/ext.lua +4 -0
- data/spec/plu_db.rb +538 -0
- data/spec/spec.rb +1 -0
- data/spec/spec_base.rb +17 -0
- data/spec/start_tyrants.sh +36 -0
- data/spec/stop_tyrants.sh +9 -0
- data/spec/tokyo_tyrant_balancer_db_spec.rb +160 -0
- data/spec/tokyo_tyrant_balancer_table_spec.rb +177 -0
- data/spec/tokyo_tyrant_query_spec.rb +159 -0
- data/spec/tokyo_tyrant_spec.rb +254 -0
- data/spec/tokyo_tyrant_table_spec.rb +301 -0
- metadata +402 -0
data/ext/tokyo_tyrant.h
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#ifndef RUBY_TOKYOTYRANT
|
2
|
+
#define RUBY_TOKYOTYRANT
|
3
|
+
|
4
|
+
#include <ruby.h>
|
5
|
+
#include <string.h>
|
6
|
+
#include <math.h>
|
7
|
+
#include <time.h>
|
8
|
+
#include <locale.h>
|
9
|
+
#include <tcrdb.h>
|
10
|
+
#include <tokyo_tyrant_module.h>
|
11
|
+
#include <tokyo_tyrant_db.h>
|
12
|
+
#include <tokyo_tyrant_table.h>
|
13
|
+
#include <tokyo_tyrant_query.h>
|
14
|
+
|
15
|
+
#define RDBVNDATA "@rdb"
|
16
|
+
#define RDBQRYVNDATA "@rdbquery"
|
17
|
+
#define NUMBUFSIZ 32
|
18
|
+
#define TTPUT 0
|
19
|
+
#define TTPUTKEEP 1
|
20
|
+
#define TTPUTCAT 2
|
21
|
+
#define TTPUTNR 3
|
22
|
+
|
23
|
+
#if !defined(RSTRING_PTR)
|
24
|
+
#define RSTRING_PTR(TC_s) (RSTRING(TC_s)->ptr)
|
25
|
+
#endif
|
26
|
+
#if !defined(RSTRING_LEN)
|
27
|
+
#define RSTRING_LEN(TC_s) (RSTRING(TC_s)->len)
|
28
|
+
#endif
|
29
|
+
#if !defined(RARRAY_LEN)
|
30
|
+
#define RARRAY_LEN(TC_a) (RARRAY(TC_a)->len)
|
31
|
+
#endif
|
32
|
+
|
33
|
+
extern VALUE mTokyoTyrant;
|
34
|
+
extern VALUE eTokyoTyrantError;
|
35
|
+
extern VALUE cDB;
|
36
|
+
extern VALUE cTable;
|
37
|
+
extern VALUE cQuery;
|
38
|
+
|
39
|
+
extern VALUE StringRaw(const char *buf, int bsiz);
|
40
|
+
extern VALUE StringValueEx(VALUE vobj);
|
41
|
+
extern TCLIST *varytolist(VALUE vary);
|
42
|
+
extern VALUE listtovary(TCLIST *list);
|
43
|
+
extern TCMAP *vhashtomap(VALUE vhash);
|
44
|
+
extern VALUE maptovhash(TCMAP *map);
|
45
|
+
extern TCMAP *varytomap(VALUE vhash);
|
46
|
+
extern TCLIST *vhashtolist(VALUE vhash);
|
47
|
+
|
48
|
+
#endif
|
@@ -0,0 +1,227 @@
|
|
1
|
+
#include <tokyo_tyrant_db.h>
|
2
|
+
|
3
|
+
static VALUE cDB_put_method(VALUE vself, VALUE vkey, VALUE vstr, int method){
|
4
|
+
bool res;
|
5
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
6
|
+
|
7
|
+
vkey = StringValueEx(vkey);
|
8
|
+
vstr = StringValueEx(vstr);
|
9
|
+
|
10
|
+
switch(method){
|
11
|
+
case TTPUT:
|
12
|
+
res = tcrdbput(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), RSTRING_PTR(vstr), RSTRING_LEN(vstr));
|
13
|
+
break;
|
14
|
+
case TTPUTKEEP:
|
15
|
+
res = tcrdbputkeep(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), RSTRING_PTR(vstr), RSTRING_LEN(vstr));
|
16
|
+
break;
|
17
|
+
case TTPUTCAT:
|
18
|
+
res = tcrdbputcat(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), RSTRING_PTR(vstr), RSTRING_LEN(vstr));
|
19
|
+
break;
|
20
|
+
case TTPUTNR:
|
21
|
+
res = tcrdbputnr(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), RSTRING_PTR(vstr), RSTRING_LEN(vstr));
|
22
|
+
break;
|
23
|
+
default:
|
24
|
+
res = false;
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
|
28
|
+
if(!res) mTokyoTyrant_exception(vself);
|
29
|
+
|
30
|
+
return Qtrue;
|
31
|
+
}
|
32
|
+
|
33
|
+
static VALUE cDB_put(VALUE vself, VALUE vkey, VALUE vstr){
|
34
|
+
return cDB_put_method(vself, vkey, vstr, TTPUT);
|
35
|
+
}
|
36
|
+
|
37
|
+
static VALUE cDB_mput(VALUE vself, VALUE vhash){
|
38
|
+
VALUE vary;
|
39
|
+
TCLIST *list, *args;
|
40
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
41
|
+
|
42
|
+
args = vhashtolist(vhash);
|
43
|
+
list = tcrdbmisc(db, "putlist", 0, args);
|
44
|
+
vary = listtovary(list);
|
45
|
+
tclistdel(args);
|
46
|
+
tclistdel(list);
|
47
|
+
return vary;
|
48
|
+
}
|
49
|
+
|
50
|
+
static VALUE cDB_putkeep(VALUE vself, VALUE vkey, VALUE vstr){
|
51
|
+
return cDB_put_method(vself, vkey, vstr, TTPUTKEEP);
|
52
|
+
}
|
53
|
+
|
54
|
+
static VALUE cDB_putcat(VALUE vself, VALUE vkey, VALUE vstr){
|
55
|
+
return cDB_put_method(vself, vkey, vstr, TTPUTCAT);
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE cDB_putnr(VALUE vself, VALUE vkey, VALUE vstr){
|
59
|
+
return cDB_put_method(vself, vkey, vstr, TTPUTNR);
|
60
|
+
}
|
61
|
+
|
62
|
+
static VALUE cDB_putshl(VALUE vself, VALUE vkey, VALUE vstr, VALUE vwidth){
|
63
|
+
bool res;
|
64
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
65
|
+
|
66
|
+
vkey = StringValueEx(vkey);
|
67
|
+
vstr = StringValueEx(vstr);
|
68
|
+
|
69
|
+
res = tcrdbputshl(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), RSTRING_PTR(vstr), RSTRING_LEN(vstr), FIXNUM_P(vwidth));
|
70
|
+
|
71
|
+
if(!res) mTokyoTyrant_exception(vself);
|
72
|
+
|
73
|
+
return Qtrue;
|
74
|
+
}
|
75
|
+
|
76
|
+
static VALUE cDB_get(VALUE vself, VALUE vkey){
|
77
|
+
VALUE vval;
|
78
|
+
char *buf;
|
79
|
+
int bsiz, ecode;
|
80
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
81
|
+
|
82
|
+
// this is ugly
|
83
|
+
vkey = StringValueEx(vkey);
|
84
|
+
if(!(buf = tcrdbget(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), &bsiz))){
|
85
|
+
if ((ecode = tcrdbecode(db))) {
|
86
|
+
if (ecode != TTENOREC) mTokyoTyrant_exception(vself);
|
87
|
+
}
|
88
|
+
return Qnil;
|
89
|
+
} else {
|
90
|
+
vval = StringRaw(buf, bsiz);
|
91
|
+
}
|
92
|
+
|
93
|
+
tcfree(buf);
|
94
|
+
return vval;
|
95
|
+
}
|
96
|
+
|
97
|
+
static VALUE cDB_mget(int argc, VALUE *argv, VALUE vself){
|
98
|
+
VALUE vkeys, vhash, vvalue;
|
99
|
+
TCMAP *recs;
|
100
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
101
|
+
rb_scan_args(argc, argv, "*", &vkeys);
|
102
|
+
|
103
|
+
// I really hope there is a better way to do this
|
104
|
+
if (RARRAY_LEN(vkeys) == 1) {
|
105
|
+
vvalue = rb_ary_entry(vkeys, 0);
|
106
|
+
switch (TYPE(vvalue)){
|
107
|
+
case T_STRING:
|
108
|
+
case T_FIXNUM:
|
109
|
+
break;
|
110
|
+
case T_ARRAY:
|
111
|
+
vkeys = vvalue;
|
112
|
+
break;
|
113
|
+
case T_STRUCT: // range is not a T_STRUCT instead of a T_OBJECT in ruby1.9?
|
114
|
+
case T_OBJECT:
|
115
|
+
vkeys = rb_convert_type(vvalue, T_ARRAY, "Array", "to_a");
|
116
|
+
break;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
Check_Type(vkeys, T_ARRAY);
|
121
|
+
|
122
|
+
recs = varytomap(vkeys);
|
123
|
+
if(!tcrdbget3(db, recs)) return Qnil;
|
124
|
+
vhash = maptovhash(recs);
|
125
|
+
tcmapdel(recs);
|
126
|
+
return vhash;
|
127
|
+
}
|
128
|
+
|
129
|
+
static VALUE cDB_vsiz(VALUE vself, VALUE vkey){
|
130
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
131
|
+
|
132
|
+
vkey = StringValueEx(vkey);
|
133
|
+
return INT2NUM(tcrdbvsiz(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey)));
|
134
|
+
}
|
135
|
+
|
136
|
+
static VALUE cDB_fetch(int argc, VALUE *argv, VALUE vself){
|
137
|
+
VALUE vkey, vrv, vforce;
|
138
|
+
rb_scan_args(argc, argv, "11", &vkey, &vforce);
|
139
|
+
if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
|
140
|
+
if(vforce == Qnil) vforce = Qfalse;
|
141
|
+
|
142
|
+
if(vforce != Qfalse || (vrv = cDB_get(vself, vkey)) == Qnil){
|
143
|
+
vrv = rb_yield(vkey);
|
144
|
+
cDB_put(vself, vkey, vrv);
|
145
|
+
}
|
146
|
+
return vrv;
|
147
|
+
}
|
148
|
+
|
149
|
+
static VALUE cDB_each(VALUE vself){
|
150
|
+
VALUE vrv;
|
151
|
+
if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
|
152
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
153
|
+
vrv = Qnil;
|
154
|
+
tcrdbiterinit(db);
|
155
|
+
int ksiz;
|
156
|
+
char *kbuf;
|
157
|
+
while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
|
158
|
+
int vsiz;
|
159
|
+
char *vbuf = tcrdbget(db, kbuf, ksiz, &vsiz);
|
160
|
+
vrv = rb_yield_values(2, rb_str_new2(kbuf), StringRaw(vbuf, vsiz));
|
161
|
+
tcfree(vbuf);
|
162
|
+
tcfree(kbuf);
|
163
|
+
}
|
164
|
+
return vrv;
|
165
|
+
}
|
166
|
+
|
167
|
+
static VALUE cDB_each_value(VALUE vself){
|
168
|
+
VALUE vrv;
|
169
|
+
if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
|
170
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
171
|
+
vrv = Qnil;
|
172
|
+
tcrdbiterinit(db);
|
173
|
+
int ksiz;
|
174
|
+
char *kbuf;
|
175
|
+
while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
|
176
|
+
int vsiz;
|
177
|
+
char *vbuf = tcrdbget(db, kbuf, ksiz, &vsiz);
|
178
|
+
vrv = rb_yield_values(1, StringRaw(vbuf, vsiz));
|
179
|
+
tcfree(vbuf);
|
180
|
+
tcfree(kbuf);
|
181
|
+
}
|
182
|
+
return vrv;
|
183
|
+
}
|
184
|
+
|
185
|
+
static VALUE cDB_values(VALUE vself){
|
186
|
+
VALUE vary;
|
187
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
188
|
+
vary = rb_ary_new2(tcrdbrnum(db));
|
189
|
+
tcrdbiterinit(db);
|
190
|
+
int ksiz;
|
191
|
+
char *kbuf;
|
192
|
+
while((kbuf = tcrdbiternext(db, &ksiz)) != NULL){
|
193
|
+
int vsiz;
|
194
|
+
char *vbuf = tcrdbget(db, kbuf, ksiz, &vsiz);
|
195
|
+
rb_ary_push(vary, StringRaw(vbuf, vsiz));
|
196
|
+
tcfree(vbuf);
|
197
|
+
tcfree(kbuf);
|
198
|
+
}
|
199
|
+
return vary;
|
200
|
+
}
|
201
|
+
|
202
|
+
void init_db(){
|
203
|
+
rb_define_method(cDB, "mput", cDB_mput, 1);
|
204
|
+
rb_define_alias(cDB, "lput", "mput"); // Rufus Compat
|
205
|
+
rb_define_method(cDB, "put", cDB_put, 2);
|
206
|
+
rb_define_alias(cDB, "[]=", "put");
|
207
|
+
rb_define_method(cDB, "putkeep", cDB_putkeep, 2);
|
208
|
+
rb_define_method(cDB, "putcat", cDB_putcat, 2);
|
209
|
+
rb_define_method(cDB, "putshl", cDB_putshl, 3);
|
210
|
+
rb_define_method(cDB, "putnr", cDB_putnr, 2);
|
211
|
+
rb_define_method(cDB, "get", cDB_get, 1);
|
212
|
+
rb_define_alias(cDB, "[]", "get");
|
213
|
+
rb_define_method(cDB, "mget", cDB_mget, -1);
|
214
|
+
rb_define_alias(cDB, "lget", "mget"); // Rufus Compat
|
215
|
+
rb_define_method(cDB, "vsiz", cDB_vsiz, 1);
|
216
|
+
/*
|
217
|
+
rb_define_method(cDB, "check_value", cDB_check_value, 1);
|
218
|
+
rb_define_alias(cDB, "has_value?", "check_value");
|
219
|
+
rb_define_alias(cDB, "value?", "check_value");
|
220
|
+
*/
|
221
|
+
|
222
|
+
rb_define_method(cDB, "fetch", cDB_fetch, -1);
|
223
|
+
rb_define_method(cDB, "each", cDB_each, 0);
|
224
|
+
rb_define_alias(cDB, "each_pair", "each");
|
225
|
+
rb_define_method(cDB, "each_value", cDB_each_value, 0);
|
226
|
+
rb_define_method(cDB, "values", cDB_values, 0);
|
227
|
+
}
|
@@ -0,0 +1,453 @@
|
|
1
|
+
#include <tokyo_tyrant_db.h>
|
2
|
+
|
3
|
+
extern TCRDB *mTokyoTyrant_getdb(VALUE vself){
|
4
|
+
TCRDB *db;
|
5
|
+
Data_Get_Struct(rb_iv_get(vself, RDBVNDATA), TCRDB, db);
|
6
|
+
return db;
|
7
|
+
}
|
8
|
+
|
9
|
+
extern void mTokyoTyrant_exception(VALUE vself){
|
10
|
+
int ecode;
|
11
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
12
|
+
|
13
|
+
ecode = tcrdbecode(db);
|
14
|
+
rb_raise(eTokyoTyrantError, tcrdberrmsg(ecode));
|
15
|
+
}
|
16
|
+
|
17
|
+
static void mTokyoTyrant_free(TCRDB *db){
|
18
|
+
tcrdbdel(db);
|
19
|
+
}
|
20
|
+
|
21
|
+
static VALUE mTokyoTyrant_server(VALUE vself){
|
22
|
+
return rb_iv_get(vself, "@server");
|
23
|
+
}
|
24
|
+
|
25
|
+
static VALUE mTokyoTyrant_close(VALUE vself){
|
26
|
+
int ecode;
|
27
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
28
|
+
|
29
|
+
if(!tcrdbclose(db)){
|
30
|
+
ecode = tcrdbecode(db);
|
31
|
+
rb_raise(eTokyoTyrantError, "close error: %s", tcrdberrmsg(ecode));
|
32
|
+
}
|
33
|
+
return Qtrue;
|
34
|
+
}
|
35
|
+
|
36
|
+
static VALUE mTokyoTyrant_connect(VALUE vself){
|
37
|
+
VALUE host, port, timeout, retry, server;
|
38
|
+
int ecode;
|
39
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
40
|
+
|
41
|
+
host = rb_iv_get(vself, "@host");
|
42
|
+
port = rb_iv_get(vself, "@port");
|
43
|
+
timeout = rb_iv_get(vself, "@timeout");
|
44
|
+
retry = rb_iv_get(vself, "@retry");
|
45
|
+
|
46
|
+
if((!tcrdbtune(db, NUM2DBL(timeout), retry == Qtrue ? RDBTRECON : 0)) ||
|
47
|
+
(!tcrdbopen(db, RSTRING_PTR(host), FIX2INT(port)))){
|
48
|
+
ecode = tcrdbecode(db);
|
49
|
+
rb_raise(eTokyoTyrantError, "open error: %s", tcrdberrmsg(ecode));
|
50
|
+
}
|
51
|
+
|
52
|
+
server = rb_str_new2(tcrdbexpr(db));
|
53
|
+
rb_iv_set(vself, "@server", server);
|
54
|
+
|
55
|
+
return Qtrue;
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE mTokyoTyrant_reconnect(VALUE vself){
|
59
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
60
|
+
if(db->fd != -1) mTokyoTyrant_close(vself);
|
61
|
+
db = tcrdbnew();
|
62
|
+
rb_iv_set(vself, RDBVNDATA, Data_Wrap_Struct(rb_cObject, 0, mTokyoTyrant_free, db));
|
63
|
+
|
64
|
+
return mTokyoTyrant_connect(vself);
|
65
|
+
}
|
66
|
+
|
67
|
+
static VALUE mTokyoTyrant_initialize(int argc, VALUE *argv, VALUE vself){
|
68
|
+
VALUE host, port, timeout, retry;
|
69
|
+
TCRDB *db;
|
70
|
+
|
71
|
+
rb_scan_args(argc, argv, "04", &host, &port, &timeout, &retry);
|
72
|
+
if(NIL_P(host)) host = rb_str_new2("127.0.0.1");
|
73
|
+
if(NIL_P(port)) port = INT2FIX(1978);
|
74
|
+
if(NIL_P(timeout)) timeout = rb_float_new(0.0);
|
75
|
+
if(NIL_P(retry)) retry = Qfalse;
|
76
|
+
|
77
|
+
rb_iv_set(vself, "@host", host);
|
78
|
+
rb_iv_set(vself, "@port", port);
|
79
|
+
rb_iv_set(vself, "@timeout", timeout);
|
80
|
+
rb_iv_set(vself, "@retry", retry);
|
81
|
+
|
82
|
+
db = tcrdbnew();
|
83
|
+
rb_iv_set(vself, RDBVNDATA, Data_Wrap_Struct(rb_cObject, 0, mTokyoTyrant_free, db));
|
84
|
+
|
85
|
+
return mTokyoTyrant_connect(vself);
|
86
|
+
}
|
87
|
+
|
88
|
+
static VALUE mTokyoTyrant_errmsg(int argc, VALUE *argv, VALUE vself){
|
89
|
+
VALUE vecode;
|
90
|
+
const char *msg;
|
91
|
+
int ecode;
|
92
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
93
|
+
rb_scan_args(argc, argv, "01", &vecode);
|
94
|
+
|
95
|
+
ecode = (vecode == Qnil) ? tcrdbecode(db) : NUM2INT(vecode);
|
96
|
+
msg = tcrdberrmsg(ecode);
|
97
|
+
return rb_str_new2(msg);
|
98
|
+
}
|
99
|
+
|
100
|
+
static VALUE mTokyoTyrant_ecode(VALUE vself){
|
101
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
102
|
+
|
103
|
+
return INT2NUM(tcrdbecode(db));
|
104
|
+
}
|
105
|
+
|
106
|
+
static VALUE mTokyoTyrant_out(VALUE vself, VALUE vkey){
|
107
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
108
|
+
|
109
|
+
vkey = StringValueEx(vkey);
|
110
|
+
return tcrdbout(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey)) ? Qtrue : Qfalse;
|
111
|
+
}
|
112
|
+
|
113
|
+
// TODO: merge out and mout?
|
114
|
+
static VALUE mTokyoTyrant_outlist(int argc, VALUE *argv, VALUE vself){
|
115
|
+
VALUE vkeys, vary, vvalue;
|
116
|
+
TCLIST *list, *result;
|
117
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
118
|
+
rb_scan_args(argc, argv, "*", &vkeys);
|
119
|
+
|
120
|
+
// I really hope there is a better way to do this
|
121
|
+
if (RARRAY_LEN(vkeys) == 1) {
|
122
|
+
vvalue = rb_ary_entry(vkeys, 0);
|
123
|
+
switch (TYPE(vvalue)){
|
124
|
+
case T_STRING:
|
125
|
+
case T_FIXNUM:
|
126
|
+
break;
|
127
|
+
case T_ARRAY:
|
128
|
+
vkeys = vvalue;
|
129
|
+
break;
|
130
|
+
case T_OBJECT:
|
131
|
+
vkeys = rb_convert_type(vvalue, T_ARRAY, "Array", "to_a");
|
132
|
+
break;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
Check_Type(vkeys, T_ARRAY);
|
136
|
+
|
137
|
+
list = varytolist(vkeys);
|
138
|
+
result = tcrdbmisc(db, "outlist", 0, list);
|
139
|
+
tclistdel(list);
|
140
|
+
vary = listtovary(result);
|
141
|
+
tclistdel(result);
|
142
|
+
return vary;
|
143
|
+
}
|
144
|
+
|
145
|
+
static VALUE mTokyoTyrant_check(VALUE vself, VALUE vkey){
|
146
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
147
|
+
|
148
|
+
vkey = StringValueEx(vkey);
|
149
|
+
return tcrdbvsiz(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey)) >= 0 ? Qtrue : Qfalse;
|
150
|
+
}
|
151
|
+
|
152
|
+
static VALUE mTokyoTyrant_iterinit(VALUE vself){
|
153
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
154
|
+
|
155
|
+
return tcrdbiterinit(db) ? Qtrue : Qfalse;
|
156
|
+
}
|
157
|
+
|
158
|
+
static VALUE mTokyoTyrant_iternext(VALUE vself){
|
159
|
+
VALUE vval;
|
160
|
+
char *vbuf;
|
161
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
162
|
+
|
163
|
+
if(!(vbuf = tcrdbiternext2(db))) return Qnil;
|
164
|
+
vval = rb_str_new2(vbuf);
|
165
|
+
tcfree(vbuf);
|
166
|
+
|
167
|
+
return vval;
|
168
|
+
}
|
169
|
+
|
170
|
+
static VALUE mTokyoTyrant_fwmkeys(int argc, VALUE *argv, VALUE vself){
|
171
|
+
VALUE vprefix, vmax, vary;
|
172
|
+
TCLIST *keys;
|
173
|
+
int max;
|
174
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
175
|
+
rb_scan_args(argc, argv, "11", &vprefix, &vmax);
|
176
|
+
|
177
|
+
vprefix = StringValueEx(vprefix);
|
178
|
+
max = (vmax == Qnil) ? -1 : NUM2INT(vmax);
|
179
|
+
keys = tcrdbfwmkeys(db, RSTRING_PTR(vprefix), RSTRING_LEN(vprefix), max);
|
180
|
+
vary = listtovary(keys);
|
181
|
+
tclistdel(keys);
|
182
|
+
return vary;
|
183
|
+
}
|
184
|
+
|
185
|
+
static VALUE mTokyoTyrant_delete_keys_with_prefix(int argc, VALUE *argv, VALUE vself){
|
186
|
+
VALUE vprefix, vmax;
|
187
|
+
TCLIST *keys;
|
188
|
+
int max;
|
189
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
190
|
+
rb_scan_args(argc, argv, "11", &vprefix, &vmax);
|
191
|
+
|
192
|
+
vprefix = StringValueEx(vprefix);
|
193
|
+
max = (vmax == Qnil) ? -1 : NUM2INT(vmax);
|
194
|
+
keys = tcrdbfwmkeys(db, RSTRING_PTR(vprefix), RSTRING_LEN(vprefix), max);
|
195
|
+
tcrdbmisc(db, "outlist", 0, keys);
|
196
|
+
tclistdel(keys);
|
197
|
+
return Qnil;
|
198
|
+
}
|
199
|
+
|
200
|
+
static VALUE mTokyoTyrant_keys(VALUE vself){
|
201
|
+
/*
|
202
|
+
VALUE vary;
|
203
|
+
char *kxstr;
|
204
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
205
|
+
vary = rb_ary_new2(tcrdbrnum(db));
|
206
|
+
tcrdbiterinit(db);
|
207
|
+
while((kxstr = tcrdbiternext2(db)) != NULL){
|
208
|
+
rb_ary_push(vary, rb_str_new2(kxstr));
|
209
|
+
}
|
210
|
+
return vary;
|
211
|
+
*/
|
212
|
+
|
213
|
+
// Using forward matching keys with an empty string is 100x faster than iternext+get
|
214
|
+
VALUE vary;
|
215
|
+
TCLIST *keys;
|
216
|
+
char *prefix;
|
217
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
218
|
+
prefix = "";
|
219
|
+
keys = tcrdbfwmkeys2(db, prefix, -1);
|
220
|
+
vary = listtovary(keys);
|
221
|
+
tclistdel(keys);
|
222
|
+
return vary;
|
223
|
+
}
|
224
|
+
|
225
|
+
static VALUE mTokyoTyrant_addint(VALUE vself, VALUE vkey, int inum){
|
226
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
227
|
+
vkey = StringValueEx(vkey);
|
228
|
+
|
229
|
+
inum = tcrdbaddint(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), inum);
|
230
|
+
return inum == INT_MIN ? Qnil : INT2NUM(inum);
|
231
|
+
}
|
232
|
+
|
233
|
+
static VALUE mTokyoTyrant_add_int(int argc, VALUE *argv, VALUE vself){
|
234
|
+
VALUE vkey, vnum;
|
235
|
+
int inum = 1;
|
236
|
+
|
237
|
+
rb_scan_args(argc, argv, "11", &vkey, &vnum);
|
238
|
+
vkey = StringValueEx(vkey);
|
239
|
+
if(NIL_P(vnum)) vnum = INT2NUM(inum);
|
240
|
+
|
241
|
+
return mTokyoTyrant_addint(vself, vkey, NUM2INT(vnum));
|
242
|
+
}
|
243
|
+
|
244
|
+
static VALUE mTokyoTyrant_get_int(VALUE vself, VALUE vkey){
|
245
|
+
return mTokyoTyrant_addint(vself, vkey, 0);
|
246
|
+
}
|
247
|
+
|
248
|
+
static VALUE mTokyoTyrant_adddouble(VALUE vself, VALUE vkey, double dnum){
|
249
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
250
|
+
|
251
|
+
vkey = StringValueEx(vkey);
|
252
|
+
dnum = tcrdbadddouble(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey), dnum);
|
253
|
+
return isnan(dnum) ? Qnil : rb_float_new(dnum);
|
254
|
+
}
|
255
|
+
|
256
|
+
static VALUE mTokyoTyrant_add_double(int argc, VALUE *argv, VALUE vself){
|
257
|
+
VALUE vkey, vnum;
|
258
|
+
double dnum = 1.0;
|
259
|
+
|
260
|
+
rb_scan_args(argc, argv, "11", &vkey, &vnum);
|
261
|
+
vkey = StringValueEx(vkey);
|
262
|
+
if(NIL_P(vnum)) vnum = rb_float_new(dnum);
|
263
|
+
|
264
|
+
return mTokyoTyrant_adddouble(vself, vkey, NUM2DBL(vnum));
|
265
|
+
}
|
266
|
+
|
267
|
+
static VALUE mTokyoTyrant_get_double(VALUE vself, VALUE vkey){
|
268
|
+
return mTokyoTyrant_adddouble(vself, vkey, 0.0);
|
269
|
+
}
|
270
|
+
|
271
|
+
static VALUE mTokyoTyrant_sync(VALUE vself){
|
272
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
273
|
+
|
274
|
+
return tcrdbsync(db) ? Qtrue : Qfalse;
|
275
|
+
}
|
276
|
+
|
277
|
+
static VALUE mTokyoTyrant_optimize(int argc, VALUE *argv, VALUE vself){
|
278
|
+
VALUE vparams;
|
279
|
+
const char *params = NULL;
|
280
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
281
|
+
rb_scan_args(argc, argv, "01", &vparams);
|
282
|
+
if(NIL_P(vparams)) vparams = Qnil;
|
283
|
+
if(vparams != Qnil) params = RSTRING_PTR(vparams);
|
284
|
+
|
285
|
+
return tcrdboptimize(db, params) ? Qtrue : Qfalse;
|
286
|
+
}
|
287
|
+
|
288
|
+
static VALUE mTokyoTyrant_vanish(VALUE vself){
|
289
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
290
|
+
|
291
|
+
return tcrdbvanish(db) ? Qtrue : Qfalse;
|
292
|
+
}
|
293
|
+
|
294
|
+
static VALUE mTokyoTyrant_copy(VALUE vself, VALUE path){
|
295
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
296
|
+
|
297
|
+
Check_Type(path, T_STRING);
|
298
|
+
return tcrdbcopy(db, RSTRING_PTR(path)) ? Qtrue : Qfalse;
|
299
|
+
}
|
300
|
+
|
301
|
+
static VALUE mTokyoTyrant_restore(VALUE vself, VALUE vpath, VALUE vts, VALUE vopts){
|
302
|
+
uint64_t ts;
|
303
|
+
int opts;
|
304
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
305
|
+
|
306
|
+
Check_Type(vpath, T_STRING);
|
307
|
+
ts = (uint64_t) FIX2INT(vts);
|
308
|
+
opts = FIX2INT(vopts);
|
309
|
+
return tcrdbrestore(db, RSTRING_PTR(vpath), ts, opts) ? Qtrue : Qfalse;
|
310
|
+
}
|
311
|
+
|
312
|
+
static VALUE mTokyoTyrant_setmst(VALUE vself, VALUE vhost, VALUE vport, VALUE vts, VALUE vopts){
|
313
|
+
uint64_t ts;
|
314
|
+
int opts;
|
315
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
316
|
+
|
317
|
+
ts = (uint64_t) FIX2INT(vts);
|
318
|
+
opts = FIX2INT(vopts);
|
319
|
+
return tcrdbsetmst(db, RSTRING_PTR(vhost), FIX2INT(vport), ts, opts) ? Qtrue : Qfalse;
|
320
|
+
}
|
321
|
+
|
322
|
+
static VALUE mTokyoTyrant_rnum(VALUE vself){
|
323
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
324
|
+
|
325
|
+
return LL2NUM(tcrdbrnum(db));
|
326
|
+
}
|
327
|
+
|
328
|
+
static VALUE mTokyoTyrant_empty(VALUE vself){
|
329
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
330
|
+
|
331
|
+
return tcrdbrnum(db) < 1 ? Qtrue : Qfalse;
|
332
|
+
}
|
333
|
+
|
334
|
+
static VALUE mTokyoTyrant_size(VALUE vself){
|
335
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
336
|
+
|
337
|
+
return LL2NUM(tcrdbsize(db));
|
338
|
+
}
|
339
|
+
|
340
|
+
static VALUE mTokyoTyrant_stat(VALUE vself){
|
341
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
342
|
+
|
343
|
+
return rb_str_new2(tcrdbstat(db));
|
344
|
+
}
|
345
|
+
|
346
|
+
static VALUE mTokyoTyrant_misc(int argc, VALUE *argv, VALUE vself){
|
347
|
+
VALUE vname, vopts, vargs, vary;
|
348
|
+
TCLIST *list, *args;
|
349
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
350
|
+
rb_scan_args(argc, argv, "13", &vname, &vopts, &vargs);
|
351
|
+
|
352
|
+
args = varytolist(vargs);
|
353
|
+
vname = StringValueEx(vname);
|
354
|
+
|
355
|
+
list = tcrdbmisc(db, RSTRING_PTR(vname), NUM2INT(vopts), args);
|
356
|
+
vary = listtovary(list);
|
357
|
+
tclistdel(list);
|
358
|
+
return vary;
|
359
|
+
}
|
360
|
+
|
361
|
+
static VALUE mTokyoTyrant_ext(VALUE vself, VALUE vext, VALUE vkey, VALUE vvalue){
|
362
|
+
int vsiz;
|
363
|
+
char *vbuf;
|
364
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
365
|
+
vext = StringValueEx(vext);
|
366
|
+
vkey = StringValueEx(vkey);
|
367
|
+
vvalue = StringValueEx(vvalue);
|
368
|
+
|
369
|
+
if(!(vbuf = tcrdbext(db, RSTRING_PTR(vext), 0, RSTRING_PTR(vkey), RSTRING_LEN(vkey), RSTRING_PTR(vvalue), RSTRING_LEN(vvalue), &vsiz))){
|
370
|
+
return Qnil;
|
371
|
+
} else {
|
372
|
+
return rb_str_new(vbuf, vsiz);
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
static VALUE mTokyoTyrant_each_key(VALUE vself){
|
377
|
+
VALUE vrv;
|
378
|
+
char *kxstr;
|
379
|
+
if(rb_block_given_p() != Qtrue) rb_raise(rb_eArgError, "no block given");
|
380
|
+
TCRDB *db = mTokyoTyrant_getdb(vself);
|
381
|
+
vrv = Qnil;
|
382
|
+
tcrdbiterinit(db);
|
383
|
+
while((kxstr = tcrdbiternext2(db)) != NULL){
|
384
|
+
vrv = rb_yield_values(1, rb_str_new2(kxstr));
|
385
|
+
}
|
386
|
+
return vrv;
|
387
|
+
}
|
388
|
+
|
389
|
+
void init_mod(){
|
390
|
+
rb_define_const(mTokyoTyrant, "ESUCCESS", INT2NUM(TTESUCCESS));
|
391
|
+
rb_define_const(mTokyoTyrant, "EINVALID", INT2NUM(TTEINVALID));
|
392
|
+
rb_define_const(mTokyoTyrant, "ENOHOST", INT2NUM(TTENOHOST));
|
393
|
+
rb_define_const(mTokyoTyrant, "EREFUSED", INT2NUM(TTEREFUSED));
|
394
|
+
rb_define_const(mTokyoTyrant, "ESEND", INT2NUM(TTESEND));
|
395
|
+
rb_define_const(mTokyoTyrant, "ERECV", INT2NUM(TTERECV));
|
396
|
+
rb_define_const(mTokyoTyrant, "EKEEP", INT2NUM(TTEKEEP));
|
397
|
+
rb_define_const(mTokyoTyrant, "ENOREC", INT2NUM(TTENOREC));
|
398
|
+
rb_define_const(mTokyoTyrant, "EMISC", INT2NUM(TTEMISC));
|
399
|
+
|
400
|
+
rb_define_const(mTokyoTyrant, "ITLEXICAL", INT2NUM(RDBITLEXICAL));
|
401
|
+
rb_define_const(mTokyoTyrant, "ITDECIMAL", INT2NUM(RDBITDECIMAL));
|
402
|
+
rb_define_const(mTokyoTyrant, "ITVOID", INT2NUM(RDBITVOID));
|
403
|
+
rb_define_const(mTokyoTyrant, "ITKEEP", INT2NUM(RDBITKEEP));
|
404
|
+
|
405
|
+
rb_define_private_method(mTokyoTyrant, "initialize", mTokyoTyrant_initialize, -1);
|
406
|
+
rb_define_private_method(mTokyoTyrant, "connect", mTokyoTyrant_connect, 0);
|
407
|
+
rb_define_method(mTokyoTyrant, "reconnect", mTokyoTyrant_reconnect, 0);
|
408
|
+
rb_define_method(mTokyoTyrant, "server", mTokyoTyrant_server, 0);
|
409
|
+
rb_define_method(mTokyoTyrant, "close", mTokyoTyrant_close, 0);
|
410
|
+
rb_define_method(mTokyoTyrant, "errmsg", mTokyoTyrant_errmsg, -1);
|
411
|
+
rb_define_method(mTokyoTyrant, "ecode", mTokyoTyrant_ecode, 0);
|
412
|
+
rb_define_method(mTokyoTyrant, "out", mTokyoTyrant_out, 1);
|
413
|
+
rb_define_alias(mTokyoTyrant, "delete", "out"); // Rufus Compat
|
414
|
+
rb_define_method(mTokyoTyrant, "outlist", mTokyoTyrant_outlist, -1);
|
415
|
+
rb_define_alias(mTokyoTyrant, "mdelete", "outlist");
|
416
|
+
rb_define_alias(mTokyoTyrant, "ldelete", "outlist"); // Rufus Compat
|
417
|
+
rb_define_method(mTokyoTyrant, "check", mTokyoTyrant_check, 1);
|
418
|
+
rb_define_alias(mTokyoTyrant, "has_key?", "check");
|
419
|
+
rb_define_alias(mTokyoTyrant, "key?", "check");
|
420
|
+
rb_define_alias(mTokyoTyrant, "include?", "check");
|
421
|
+
rb_define_alias(mTokyoTyrant, "member?", "check");
|
422
|
+
rb_define_method(mTokyoTyrant, "iterinit", mTokyoTyrant_iterinit, 0);
|
423
|
+
rb_define_method(mTokyoTyrant, "iternext", mTokyoTyrant_iternext, 0);
|
424
|
+
rb_define_method(mTokyoTyrant, "fwmkeys", mTokyoTyrant_fwmkeys, -1);
|
425
|
+
rb_define_method(mTokyoTyrant, "delete_keys_with_prefix", mTokyoTyrant_delete_keys_with_prefix, -1);// Rufus Compat
|
426
|
+
rb_define_alias(mTokyoTyrant, "dfwmkeys", "delete_keys_with_prefix");
|
427
|
+
rb_define_method(mTokyoTyrant, "keys", mTokyoTyrant_keys, 0);
|
428
|
+
rb_define_method(mTokyoTyrant, "add_int", mTokyoTyrant_add_int, -1);
|
429
|
+
rb_define_alias(mTokyoTyrant, "addint", "add_int");
|
430
|
+
rb_define_alias(mTokyoTyrant, "increment", "add_int");
|
431
|
+
rb_define_method(mTokyoTyrant, "get_int", mTokyoTyrant_get_int, 1);
|
432
|
+
rb_define_method(mTokyoTyrant, "add_double", mTokyoTyrant_add_double, -1);
|
433
|
+
rb_define_alias(mTokyoTyrant, "adddouble", "add_double");
|
434
|
+
rb_define_method(mTokyoTyrant, "get_double", mTokyoTyrant_get_double, 1);
|
435
|
+
rb_define_method(mTokyoTyrant, "sync", mTokyoTyrant_sync, 0);
|
436
|
+
rb_define_method(mTokyoTyrant, "optimize", mTokyoTyrant_optimize, -1);
|
437
|
+
rb_define_method(mTokyoTyrant, "vanish", mTokyoTyrant_vanish, 0);
|
438
|
+
rb_define_alias(mTokyoTyrant, "clear", "vanish");
|
439
|
+
rb_define_method(mTokyoTyrant, "copy", mTokyoTyrant_copy, 1);
|
440
|
+
rb_define_method(mTokyoTyrant, "restore", mTokyoTyrant_restore, 2);
|
441
|
+
rb_define_method(mTokyoTyrant, "setmst", mTokyoTyrant_setmst, 4);
|
442
|
+
rb_define_method(mTokyoTyrant, "rnum", mTokyoTyrant_rnum, 0);
|
443
|
+
rb_define_alias(mTokyoTyrant, "count", "rnum");
|
444
|
+
rb_define_method(mTokyoTyrant, "empty?", mTokyoTyrant_empty, 0);
|
445
|
+
rb_define_alias(mTokyoTyrant, "size", "rnum"); // Rufus Compat
|
446
|
+
rb_define_method(mTokyoTyrant, "db_size", mTokyoTyrant_size, 0); // Rufus Compat
|
447
|
+
rb_define_alias(mTokyoTyrant, "length", "size");
|
448
|
+
rb_define_method(mTokyoTyrant, "stat", mTokyoTyrant_stat, 0);
|
449
|
+
rb_define_method(mTokyoTyrant, "misc", mTokyoTyrant_misc, -1);
|
450
|
+
rb_define_method(mTokyoTyrant, "ext", mTokyoTyrant_ext, 3);
|
451
|
+
rb_define_alias(mTokyoTyrant, "run", "ext");
|
452
|
+
rb_define_method(mTokyoTyrant, "each_key", mTokyoTyrant_each_key, 0);
|
453
|
+
}
|