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
@@ -0,0 +1,15 @@
|
|
1
|
+
================================================================
|
2
|
+
Thanks to all of the following for their valuable suggestions
|
3
|
+
or contributions.
|
4
|
+
================================================================
|
5
|
+
|
6
|
+
|
7
|
+
mixi Inc. and and its developers
|
8
|
+
- allowing me to develop and publish Tokyo Tyrant as business work
|
9
|
+
|
10
|
+
tamtam
|
11
|
+
- added Solaris support
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
== END OF FILE ==
|
@@ -0,0 +1,211 @@
|
|
1
|
+
/*
|
2
|
+
* Style Sheets commonly used by documents of Tokyo Cabinet
|
3
|
+
*/
|
4
|
+
|
5
|
+
html {
|
6
|
+
margin: 0em 0em;
|
7
|
+
padding: 0em 0em;
|
8
|
+
background: #eeeeee none;
|
9
|
+
}
|
10
|
+
body {
|
11
|
+
margin: 1em 2em;
|
12
|
+
padding: 0em 0em;
|
13
|
+
background: #eeeeee none;
|
14
|
+
color: #111111;
|
15
|
+
}
|
16
|
+
|
17
|
+
hr {
|
18
|
+
margin: 2.5em 0em 1.5em 0em;
|
19
|
+
height: 1px;
|
20
|
+
border: none;
|
21
|
+
background: #999999 none;
|
22
|
+
color: #999999;
|
23
|
+
}
|
24
|
+
|
25
|
+
h1,h2,h3,h4,h5,h6 {
|
26
|
+
font-weight: bold;
|
27
|
+
}
|
28
|
+
h1 {
|
29
|
+
margin: 1.0em 0em 1.3em 0em;
|
30
|
+
padding: 0em 0em;
|
31
|
+
font-size: 180%;
|
32
|
+
color: #000000;
|
33
|
+
}
|
34
|
+
h2 {
|
35
|
+
margin: 1.0em 0em 1.0em 0.2em;
|
36
|
+
padding: 0.5em 0.5em;
|
37
|
+
width: 60%;
|
38
|
+
border-left: solid 0.6em #445555;
|
39
|
+
border-bottom: solid 1px #bbbbbb;
|
40
|
+
font-size: 150%;
|
41
|
+
color: #000011;
|
42
|
+
}
|
43
|
+
h3 {
|
44
|
+
margin: 0.8em 0em 0.5em 0.2em;
|
45
|
+
padding: 0em 0em;
|
46
|
+
font-size: 120%;
|
47
|
+
color: #001111;
|
48
|
+
}
|
49
|
+
|
50
|
+
p {
|
51
|
+
margin: 0.8em 0em;
|
52
|
+
line-height: 140%;
|
53
|
+
text-indent: 0.8em;
|
54
|
+
}
|
55
|
+
|
56
|
+
div,pre,table {
|
57
|
+
margin: 0.8em 1.5em;
|
58
|
+
}
|
59
|
+
|
60
|
+
div.note,div.navi {
|
61
|
+
text-align: right;
|
62
|
+
margin: 0em 0.5em;
|
63
|
+
color: #333333;
|
64
|
+
}
|
65
|
+
span.void {
|
66
|
+
color: #888888;
|
67
|
+
}
|
68
|
+
|
69
|
+
div.logo {
|
70
|
+
text-align: center;
|
71
|
+
margin: 3em 0em;
|
72
|
+
}
|
73
|
+
div.logo img {
|
74
|
+
border: inset 2px #ccccdd;
|
75
|
+
}
|
76
|
+
div.illust {
|
77
|
+
margin: 1em 0em;
|
78
|
+
text-align: center;
|
79
|
+
}
|
80
|
+
div.illust img {
|
81
|
+
border: solid 1px #ccccdd;
|
82
|
+
}
|
83
|
+
|
84
|
+
pre {
|
85
|
+
padding: 0.2em;
|
86
|
+
background-color: #ddddee;
|
87
|
+
border: 1px solid #bbbbcc;
|
88
|
+
font-size: 95%;
|
89
|
+
}
|
90
|
+
|
91
|
+
li,dt,dd {
|
92
|
+
line-height: 130%;
|
93
|
+
}
|
94
|
+
dt {
|
95
|
+
margin-left: 1.2em;
|
96
|
+
}
|
97
|
+
dd {
|
98
|
+
margin-left: 2.5em;
|
99
|
+
text-indent: -0.3em;
|
100
|
+
}
|
101
|
+
dl.api {
|
102
|
+
margin-top: -0.2em;
|
103
|
+
}
|
104
|
+
dl.api dd {
|
105
|
+
margin-left: 3.0em;
|
106
|
+
font-size: 95%;
|
107
|
+
color: #333333;
|
108
|
+
}
|
109
|
+
ul {
|
110
|
+
margin: 0.5em 2.0em;
|
111
|
+
padding: 0em;
|
112
|
+
}
|
113
|
+
ul.options {
|
114
|
+
list-style-type: none;
|
115
|
+
margin: 0.5em 1.5em;
|
116
|
+
font-size: 95%;
|
117
|
+
color: #333333;
|
118
|
+
}
|
119
|
+
ul ul {
|
120
|
+
margin-top: 0em;
|
121
|
+
margin-bottom: 0em;
|
122
|
+
}
|
123
|
+
|
124
|
+
table {
|
125
|
+
border-collapse: collapse;
|
126
|
+
}
|
127
|
+
td {
|
128
|
+
text-align: left;
|
129
|
+
vertical-align: top;
|
130
|
+
padding: 0.1em 0.5em;
|
131
|
+
border: solid 1px #aaaabb;
|
132
|
+
font-size: 95%;
|
133
|
+
}
|
134
|
+
td.label {
|
135
|
+
border: none;
|
136
|
+
font-size: 80%;
|
137
|
+
color: #333333;
|
138
|
+
}
|
139
|
+
td.number {
|
140
|
+
text-align: right;
|
141
|
+
}
|
142
|
+
|
143
|
+
a {
|
144
|
+
color: #0022aa;
|
145
|
+
text-decoration: none;
|
146
|
+
}
|
147
|
+
a:hover,a:focus {
|
148
|
+
color: #0033ee;
|
149
|
+
text-decoration: underline;
|
150
|
+
}
|
151
|
+
code,kbd {
|
152
|
+
font-style: normal;
|
153
|
+
font-weight: bold;
|
154
|
+
font-size: 100%;
|
155
|
+
color: #001111;
|
156
|
+
}
|
157
|
+
var {
|
158
|
+
padding: 0em 0.15em 0em 0em;
|
159
|
+
font-style: italic;
|
160
|
+
color: #001122;
|
161
|
+
}
|
162
|
+
|
163
|
+
@media print {
|
164
|
+
html,body {
|
165
|
+
margin: 0em 0em;
|
166
|
+
background-color: #ffffff;
|
167
|
+
color: #000000;
|
168
|
+
}
|
169
|
+
h1 {
|
170
|
+
padding: 8em 0em 0.5em 0em;
|
171
|
+
text-align: center;
|
172
|
+
}
|
173
|
+
h2 {
|
174
|
+
page-break-before: always;
|
175
|
+
}
|
176
|
+
div.note {
|
177
|
+
text-align: center;
|
178
|
+
}
|
179
|
+
div.navi,div.logo {
|
180
|
+
display: none;
|
181
|
+
}
|
182
|
+
hr {
|
183
|
+
display: none;
|
184
|
+
}
|
185
|
+
pre {
|
186
|
+
margin: 0.8em 0.8em;
|
187
|
+
background-color: #ffffff;
|
188
|
+
border: 1px solid #aaaaaa;
|
189
|
+
font-size: 90%;
|
190
|
+
}
|
191
|
+
a,code,kbd {
|
192
|
+
color: #000000;
|
193
|
+
text-decoration: none;
|
194
|
+
}
|
195
|
+
h1,h2,h3 {
|
196
|
+
font-family: sans-serif;
|
197
|
+
}
|
198
|
+
p,div,li,dt,dd {
|
199
|
+
font-family: serif;
|
200
|
+
}
|
201
|
+
pre,code,kbd {
|
202
|
+
font-family: monospace;
|
203
|
+
}
|
204
|
+
dd {
|
205
|
+
font-size: 90%;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
/* END OF FILE */
|
@@ -0,0 +1,79 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
|
7
|
+
<head>
|
8
|
+
<meta http-equiv="Content-Language" content="en" />
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
10
|
+
<meta http-equiv="Content-Style-Type" content="text/css" />
|
11
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
12
|
+
<meta name="author" content="Mikio Hirabayashi" />
|
13
|
+
<meta name="keywords" content="Tokyo Tyrant, tokyotyrant, Tokyo Cabinet, database, KVS, memcached, REST" />
|
14
|
+
<meta name="description" content="homepage of Tokyo Tyrant" />
|
15
|
+
<link rel="contents" href="./" />
|
16
|
+
<link rel="stylesheet" href="common.css" />
|
17
|
+
<link rev="made" href="mailto:hirarin@gmail.com" />
|
18
|
+
<title>Tokyo Tyrant: network interface of Tokyo Cabinet</title>
|
19
|
+
</head>
|
20
|
+
|
21
|
+
<body>
|
22
|
+
|
23
|
+
<h1 id="headline">Tokyo Tyrant: network interface of Tokyo Cabinet</h1>
|
24
|
+
|
25
|
+
<div class="note">Copyright (C) 2007-2009 Mikio Hirabayashi</div>
|
26
|
+
<div class="note">Last Update: Mon, 31 Aug 2009 23:04:22 +0900</div>
|
27
|
+
|
28
|
+
<hr />
|
29
|
+
|
30
|
+
<h2 id="overview">Overview</h2>
|
31
|
+
|
32
|
+
<p>Tokyo Tyrant is a package of network interface to the DBM called Tokyo Cabinet. Though the DBM has high performance, you might bother in case that multiple processes share the same database, or remote processes access the database. Thus, Tokyo Tyrant is provided for concurrent and remote connections to Tokyo Cabinet. It is composed of the server process managing a database and its access library for client applications.</p>
|
33
|
+
|
34
|
+
<p>Tokyo Tyrant is written in the C language, and provided as API of C, Perl, and Ruby. Tokyo Tyrant is available on platforms which have API conforming to C99 and POSIX. Tokyo Tyrant is a free software licensed under the GNU Lesser General Public License.</p>
|
35
|
+
|
36
|
+
<hr />
|
37
|
+
|
38
|
+
<h2 id="documents">Documents</h2>
|
39
|
+
|
40
|
+
<p>The following are documents of Tokyo Tyrant. They are contained also in the source package.</p>
|
41
|
+
|
42
|
+
<ul>
|
43
|
+
<li><a href="spex.html">Fundamental Specifications</a></li>
|
44
|
+
</ul>
|
45
|
+
|
46
|
+
<ul>
|
47
|
+
<li><a href="perldoc/">Specifications of Perl API</a></li>
|
48
|
+
<li><a href="rubydoc/">Specifications of Ruby API</a></li>
|
49
|
+
</ul>
|
50
|
+
|
51
|
+
<hr />
|
52
|
+
|
53
|
+
<h2 id="packages">Packages</h2>
|
54
|
+
|
55
|
+
<p>The following are the source packages of Tokyo Tyrant. As for binary packages, see the site of each distributor.</p>
|
56
|
+
|
57
|
+
<ul>
|
58
|
+
<li><a href="tokyotyrant-1.1.39.tar.gz">Latest Source Package (version 1.1.39)</a></li>
|
59
|
+
<li><a href="pastpkg/">Past Versions</a></li>
|
60
|
+
</ul>
|
61
|
+
|
62
|
+
<ul>
|
63
|
+
<li><a href="perlpkg/">API for Perl</a></li>
|
64
|
+
<li><a href="rubypkg/">API for Ruby</a></li>
|
65
|
+
</ul>
|
66
|
+
|
67
|
+
<hr />
|
68
|
+
|
69
|
+
<h2 id="information">Information</h2>
|
70
|
+
|
71
|
+
<p>Tokyo Tyrant was written and is maintained by <a href="http://1978th.net/">Mikio Hirabayashi</a>. You can contact the author by e-mail to `hirarin@gmail.com'.</p>
|
72
|
+
|
73
|
+
<hr />
|
74
|
+
|
75
|
+
</body>
|
76
|
+
|
77
|
+
</html>
|
78
|
+
|
79
|
+
<!-- END OF FILE -->
|
@@ -0,0 +1,2264 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
|
3
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
|
7
|
+
<head>
|
8
|
+
<meta http-equiv="Content-Language" content="en" />
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
10
|
+
<meta http-equiv="Content-Style-Type" content="text/css" />
|
11
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
12
|
+
<meta name="author" content="Mikio Hirabayashi" />
|
13
|
+
<meta name="keywords" content="Tokyo Tyrant, tokyotyrant, Tokyo Cabinet, database, KVS, memcached, REST" />
|
14
|
+
<meta name="description" content="specifications of Tokyo Tyrant" />
|
15
|
+
<link rel="contents" href="./" />
|
16
|
+
<link rel="stylesheet" href="common.css" />
|
17
|
+
<link rev="made" href="mailto:hirarin@gmail.com" />
|
18
|
+
<title>Fundamental Specifications of Tokyo Tyrant Version 1</title>
|
19
|
+
</head>
|
20
|
+
|
21
|
+
<body>
|
22
|
+
|
23
|
+
<h1 id="headline">Fundamental Specifications of Tokyo Tyrant Version 1</h1>
|
24
|
+
|
25
|
+
<div class="note">Copyright (C) 2007-2009 Mikio Hirabayashi</div>
|
26
|
+
<div class="note">Last Update: Mon, 31 Aug 2009 23:04:22 +0900</div>
|
27
|
+
|
28
|
+
<hr />
|
29
|
+
|
30
|
+
<h2 id="contents">Table of Contents</h2>
|
31
|
+
|
32
|
+
<ol>
|
33
|
+
<li><a href="#introduction">Introduction</a></li>
|
34
|
+
<li><a href="#installation">Installation</a></li>
|
35
|
+
<li><a href="#serverprog">Server Programs</a></li>
|
36
|
+
<li><a href="#clientprog">Client Programs</a></li>
|
37
|
+
<li><a href="#tcrdbapi">Remote Database API</a></li>
|
38
|
+
<li><a href="#luaext">Lua Extension</a></li>
|
39
|
+
<li><a href="#protocol">Protocol</a></li>
|
40
|
+
<li><a href="#tutorial">Tutorial</a></li>
|
41
|
+
<li><a href="#license">License</a></li>
|
42
|
+
</ol>
|
43
|
+
|
44
|
+
<hr />
|
45
|
+
|
46
|
+
<h2 id="introduction">Introduction</h2>
|
47
|
+
|
48
|
+
<p>Tokyo Tyrant is a package of network interface to the DBM called Tokyo Cabinet. Though the DBM has high performance, you might bother in case that multiple processes share the same database, or remote processes access the database. Thus, Tokyo Tyrant is provided for concurrent and remote connections to Tokyo Cabinet. It is composed of the server process managing a database and its access library for client applications.</p>
|
49
|
+
|
50
|
+
<p>The server features high concurrency due to thread-pool modeled implementation and the epoll/kqueue mechanism of the modern Linux/*BSD kernel. The server and its clients communicate with each other by simple binary protocol on TCP/IP. Protocols compatible with memcached and HTTP are also supported so that almost all principal platforms and programming languages can use Tokyo Tyrant. High availability and high integrity are also featured due to such mechanisms as hot backup, update logging, and replication. The server can embed Lua, a lightweight script language so that you can define arbitrary operations of the database.</p>
|
51
|
+
|
52
|
+
<p>Because the server uses the abstract API of Tokyo Cabinet, all of the six APIs: the on-memory hash database API, the on-memory tree database API, the hash API, the B+ tree database API, the fixed-length database API, and the table database API, are available from the client with the common interface. Moreover, the table extension is provided to use specifidc features of the table database.</p>
|
53
|
+
|
54
|
+
|
55
|
+
<p><em>As for now, the server works on Linux, FreeBSD, Mac OS X, Solaris only.</em></p>
|
56
|
+
|
57
|
+
<hr />
|
58
|
+
|
59
|
+
<h2 id="installation">Installation</h2>
|
60
|
+
|
61
|
+
<p>Install the latest version of Tokyo Cabinet beforehand and get the package of Tokyo Tyrant.</p>
|
62
|
+
|
63
|
+
<p>When an archive file of Tokyo Tyrant is extracted, change the current working directory to the generated directory and perform installation.</p>
|
64
|
+
|
65
|
+
<p>Run the configuration script. To enable the Lua extension, add the `--enable-lua' option.</p>
|
66
|
+
|
67
|
+
<pre>./configure
|
68
|
+
</pre>
|
69
|
+
|
70
|
+
<p>Build programs.</p>
|
71
|
+
|
72
|
+
<pre>make
|
73
|
+
</pre>
|
74
|
+
|
75
|
+
<p>Install programs. This operation must be carried out by the root user.</p>
|
76
|
+
|
77
|
+
<pre>make install
|
78
|
+
</pre>
|
79
|
+
|
80
|
+
<p>When a series of work finishes, the following files will be installed.</p>
|
81
|
+
|
82
|
+
<pre>/usr/local/include/ttutil.h
|
83
|
+
/usr/local/include/tculog.h
|
84
|
+
/usr/local/include/tcrdb.h
|
85
|
+
/usr/local/lib/libtokyotyrant.a
|
86
|
+
/usr/local/lib/libtokyotyrant.so.x.y.z
|
87
|
+
/usr/local/lib/libtokyotyrant.so.x
|
88
|
+
/usr/local/lib/libtokyotyrant.so
|
89
|
+
/usr/local/lib/ttskelmock.so
|
90
|
+
/usr/local/lib/ttskeldir.so
|
91
|
+
/usr/local/lib/ttskelproxy.so
|
92
|
+
/usr/local/lib/ttskelnull.so
|
93
|
+
/usr/local/lib/pkgconfig/tokyotyrant.pc
|
94
|
+
/usr/local/bin/ttserver
|
95
|
+
/usr/local/bin/ttultest
|
96
|
+
/usr/local/bin/ttulmgr
|
97
|
+
/usr/local/bin/tcrtest
|
98
|
+
/usr/local/bin/tcrmttest
|
99
|
+
/usr/local/bin/tcrmgr
|
100
|
+
/usr/local/sbin/ttservctl
|
101
|
+
/usr/local/share/tokyotyrant/...
|
102
|
+
/usr/local/man/man1/...
|
103
|
+
/usr/local/man/man3/...
|
104
|
+
</pre>
|
105
|
+
|
106
|
+
<p>To test the server, perform the following command. To finish it, press Ctrl-C on the terminal.</p>
|
107
|
+
|
108
|
+
<pre>ttserver
|
109
|
+
</pre>
|
110
|
+
|
111
|
+
<p>To test the client connecting to the above running server, perform the following command on another terminal.</p>
|
112
|
+
|
113
|
+
<pre>make check
|
114
|
+
</pre>
|
115
|
+
|
116
|
+
<hr />
|
117
|
+
|
118
|
+
<h2 id="serverprog">Server Programs</h2>
|
119
|
+
|
120
|
+
<h3 id="serverprog_ttserver">ttserver</h3>
|
121
|
+
|
122
|
+
<p>The command `<code>ttserver</code>' runs the server managing a database instance. Because the database is treated by the abstract API of Tokyo Cabinet, you can choose the scheme on start-up of the server. Supported schema are on-memory hash database, on-memory tree database, hash database, and B+ tree database. This command is used in the following format. `<var>dbname</var>' specifies the database name. If it is omitted, on-memory hash database is specified.</p>
|
123
|
+
|
124
|
+
<dl class="api">
|
125
|
+
<dt><code>ttserver [-host <var>name</var>] [-port <var>num</var>] [-thnum <var>num</var>] [-tout <var>num</var>] [-dmn] [-pid <var>path</var>] [-kl] [-log <var>path</var>] [-ld|-le] [-ulog <var>path</var>] [-ulim <var>num</var>] [-uas] [-sid <var>num</var>] [-mhost <var>name</var>] [-mport <var>num</var>] [-rts <var>path</var>] [-rcc] [-skel <var>name</var>] [-mul <var>num</var>] [-ext <var>path</var>] [-extpc <var>name</var> <var>period</var>] [-mask <var>expr</var>] [-unmask <var>expr</var>] [<var>dbname</var>]</code></dt>
|
126
|
+
</dl>
|
127
|
+
|
128
|
+
<p>Options feature the following.</p>
|
129
|
+
|
130
|
+
<ul class="options">
|
131
|
+
<li><code>-host <var>name</var></code> : specify the host name or the address of the server. By default, every network address is bound.</li>
|
132
|
+
<li><code>-port <var>num</var></code> : specify the port number. By default, it is 1978.</li>
|
133
|
+
<li><code>-thnum <var>num</var></code> : specify the number of worker threads. By default, it is 8.</li>
|
134
|
+
<li><code>-tout <var>num</var></code> : specify the timeout of each session in seconds. By default, no timeout is specified.</li>
|
135
|
+
<li><code>-dmn</code> : work as a daemon process.</li>
|
136
|
+
<li><code>-pid <var>path</var></code> : output the process ID into the file.</li>
|
137
|
+
<li><code>-kl</code> : kill the existing process if the process ID file is detected.</li>
|
138
|
+
<li><code>-log <var>path</var></code> : output log messages into the file.</li>
|
139
|
+
<li><code>-ld</code> : log debug messages also.</li>
|
140
|
+
<li><code>-le</code> : log error messages only.</li>
|
141
|
+
<li><code>-ulog <var>path</var></code> : specify the update log directory.</li>
|
142
|
+
<li><code>-ulim <var>num</var></code> : specify the limit size of each update log file.</li>
|
143
|
+
<li><code>-uas</code> : use asynchronous I/O for the update log.</li>
|
144
|
+
<li><code>-sid <var>num</var></code> : specify the server ID.</li>
|
145
|
+
<li><code>-mhost <var>name</var></code> : specify the host name of the replication master server.</li>
|
146
|
+
<li><code>-mport <var>num</var></code> : specify the port number of the replication master server.</li>
|
147
|
+
<li><code>-rts <var>path</var></code> : specify the replication time stamp file.</li>
|
148
|
+
<li><code>-rcc</code> : check consistency of replication.</li>
|
149
|
+
<li><code>-skel <var>name</var></code> : specify the name of the skeleton database library.</li>
|
150
|
+
<li><code>-mul <var>num</var></code> : specify the division number of the multiple database mechanism.</li>
|
151
|
+
<li><code>-ext <var>path</var></code> : specify the script language extension file.</li>
|
152
|
+
<li><code>-extpc <var>name</var> <var>period</var></code> : specify the function name and the calling period of a periodic command.</li>
|
153
|
+
<li><code>-mask <var>expr</var></code> : specify the names of forbidden commands.</li>
|
154
|
+
<li><code>-unmask <var>expr</var></code> : specify the names of allowed commands.</li>
|
155
|
+
</ul>
|
156
|
+
|
157
|
+
<p>To terminate the server normally, send SIGINT or SIGTERM to the process. It is okay to press Ctrl-C on the controlling terminal. To restart the server, send SIGHUP to the process. If the port number is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter. This command returns 0 on success, another on failure.</p>
|
158
|
+
|
159
|
+
<p>The naming convention of the database is specified by the abstract API of Tokyo Cabinet. If the name is "*", the database will be an on-memory hash database. If it is "+", the database will be an on-memory tree database. If its suffix is ".tch", the database will be a hash database. If its suffix is ".tcb", the database will be a B+ tree database. If its suffix is ".tcf", the database will be a fixed-length database. If its suffix is ".tct", the database will be a table database. Otherwise, this function fails. Tuning parameters can trail the name, separated by "#". Each parameter is composed of the name and the value, separated by "=". On-memory hash database supports "bnum", "capnum", and "capsiz". On-memory tree database supports "capnum" and "capsiz". Hash database supports "mode", "bnum", "apow", "fpow", "opts", "rcnum", "xmsiz", and "dfunit". B+ tree database supports "mode", "lmemb", "nmemb", "bnum", "apow", "fpow", "opts", "lcnum", "ncnum", "xmsiz", and "dfunit". Fixed-length database supports "mode", "width", and "limsiz". Table database supports "mode", "bnum", "apow", "fpow", "opts", "rcnum", "lcnum", "ncnum", "xmsiz", "dfunit", and "idx". The tuning parameter "capnum" specifies the capacity number of records. "capsiz" specifies the capacity size of using memory. Records spilled the capacity are removed by the storing order. "mode" can contain "w" of writer, "r" of reader, "c" of creating, "t" of truncating, "e" of no locking, and "f" of non-blocking lock. The default mode is relevant to "wc". "opts" can contains "l" of large option, "d" of Deflate option, "b" of BZIP2 option, and "t" of TCBS option. "idx" specifies the column name of an index and its type separated by ":". For example, "casket.tch#bnum=1000000#opts=ld" means that the name of the database file is "casket.tch", and the bucket number is 1000000, and the options are large and Deflate.</p>
|
160
|
+
|
161
|
+
<p>The command mask expression is a list of command names separated by ",". For example, "out,vanish,copy" means a set of "out", "vanish", and "copy". Commands of the memcached compatible protocol and the HTTP compatible protocol are also forbidden or allowed, related by the mask of each original command. Moreover, there are meta expressions. "all" means all commands. "allorg" means all commands of the original binary protocol. "allmc" means all commands of the memcached compatible protocol. "allhttp" means all commands of the HTTP compatible protocol. "allread" is the abbreviation of `get', `mget', `vsiz', `iterinit', `iternext', `fwmkeys', `rnum', `size', and `stat'. "allwrite" is the abbreviation of `put', `putkeep', `putcat', `putshl', `putnr', `out', `addint', `adddouble', `vanish', and `misc'. "allmanage" is the abbreviation of `sync', `optimize', `copy', `restore', and `setmst'. "repl" means replication as master. "slave" means replication as slave.</p>
|
162
|
+
|
163
|
+
<h3 id="serverprog_ttservctl">ttservctl</h3>
|
164
|
+
|
165
|
+
<p>The command `<code>ttservctl</code>' is the startup script of the server. It can be called by the RC script of the bootstrap process of the operating system. This command is used in the following format.</p>
|
166
|
+
|
167
|
+
<dl class="api">
|
168
|
+
<dt><code>ttservctl start</code></dt>
|
169
|
+
<dd>Startup the server.</dd>
|
170
|
+
<dt><code>ttservctl stop</code></dt>
|
171
|
+
<dd>Stop the server.</dd>
|
172
|
+
<dt><code>ttservctl restart</code></dt>
|
173
|
+
<dd>Restart the server.</dd>
|
174
|
+
<dt><code>ttservctl hup</code></dt>
|
175
|
+
<dd>Send HUP signal to the server for log rotation.</dd>
|
176
|
+
</dl>
|
177
|
+
|
178
|
+
<p>The database is placed as "/var/ttserver/casket.tch". The log and related files are also placed in "/var/ttserver". This command returns 0 on success, another on failure.</p>
|
179
|
+
|
180
|
+
<h3 id="serverprog_ttulmgr">ttulmgr</h3>
|
181
|
+
|
182
|
+
<p>The command `<code>ttulmgr</code>' is the utility to export and import the update log. It is useful to filter the update log with such text utilities as `<code>grep</code>' and `<code>sed</code>'. This command is used in the following format. `<var>upath</var>' specifies the update log directory.</p>
|
183
|
+
|
184
|
+
<dl class="api">
|
185
|
+
<dt><code>ttulmgr export [-ts <var>num</var>] [-sid <var>num</var>] <var>upath</var></code></dt>
|
186
|
+
<dd>Export the update log as TSV text data to the standard output.</dd>
|
187
|
+
<dt><code>ttulmgr import <var>upath</var></code></dt>
|
188
|
+
<dd>Import TSV text data from the standard input to the update log.</dd>
|
189
|
+
</dl>
|
190
|
+
|
191
|
+
<p>Options feature the following.</p>
|
192
|
+
|
193
|
+
<ul class="options">
|
194
|
+
<li><code>-ts <var>num</var></code> : specify the beginning time stamp.</li>
|
195
|
+
<li><code>-sid <var>num</var></code> : specify the self server ID.</li>
|
196
|
+
</ul>
|
197
|
+
|
198
|
+
<p>This command returns 0 on success, another on failure.</p>
|
199
|
+
|
200
|
+
<hr />
|
201
|
+
|
202
|
+
<h2 id="clientprog">Client Programs</h2>
|
203
|
+
|
204
|
+
<h3 id="clientprog_tcrtest">tcrtest</h3>
|
205
|
+
|
206
|
+
<p>The command `<code>tcrtest</code>' is a utility for facility test and performance test. This command is used in the following format. `<var>host</var>' specifies the host name of the server. `<var>rnum</var>' specifies the number of iterations.</p>
|
207
|
+
|
208
|
+
<dl class="api">
|
209
|
+
<dt><code>tcrtest write [-port <var>num</var>] [-cnum <var>num</var>] [-tout <var>num</var>] [-nr] [-rnd] <var>host</var> <var>rnum</var></code></dt>
|
210
|
+
<dd>Store records with keys of 8 bytes. They change as `00000001', `00000002'...</dd>
|
211
|
+
<dt><code>tcrtest read [-port <var>num</var>] [-cnum <var>num</var>] [-tout <var>num</var>] [-mul <var>num</var>] [-rnd] <var>host</var></code></dt>
|
212
|
+
<dd>Retrieve all records of the database above.</dd>
|
213
|
+
<dt><code>tcrtest remove [-port <var>num</var>] [-cnum <var>num</var>] [-tout <var>num</var>] [-rnd] <var>host</var></code></dt>
|
214
|
+
<dd>Remove all records of the database above.</dd>
|
215
|
+
<dt><code>tcrtest rcat [-port <var>num</var>] [-cnum <var>num</var>] [-tout <var>num</var>] [-shl <var>num</var>] [-dai|-dad] [-ext <var>name</var>] [-xlr|-xlg] <var>host</var> <var>rnum</var></code></dt>
|
216
|
+
<dd>Store records with partway duplicated keys using concatenate mode.</dd>
|
217
|
+
<dt><code>tcrtest misc [-port <var>num</var>] [-cnum <var>num</var>] [-tout <var>num</var>] <var>host</var> <var>rnum</var></code></dt>
|
218
|
+
<dd>Perform miscellaneous test of various operations.</dd>
|
219
|
+
<dt><code>tcrtest wicked [-port <var>num</var>] [-cnum <var>num</var>] [-tout <var>num</var>] <var>host</var> <var>rnum</var></code></dt>
|
220
|
+
<dd>Perform updating operations of list and map selected at random.</dd>
|
221
|
+
<dt><code>tcrtest table [-port <var>num</var>] [-cnum <var>num</var>] [-tout <var>num</var>] [-exp <var>num</var>] <var>host</var> <var>rnum</var></code></dt>
|
222
|
+
<dd>Perform miscellaneous test of the table extension.</dd>
|
223
|
+
</dl>
|
224
|
+
|
225
|
+
<p>Options feature the following.</p>
|
226
|
+
|
227
|
+
<ul class="options">
|
228
|
+
<li><code>-port <var>num</var></code> : specify the port number.</li>
|
229
|
+
<li><code>-cnum <var>num</var></code> : specify the number of connections.</li>
|
230
|
+
<li><code>-tout <var>num</var></code> : specify the timeout of each session in seconds.</li>
|
231
|
+
<li><code>-nr</code> : use the function `tcrdbputnr' instead of `tcrdbput'.</li>
|
232
|
+
<li><code>-rnd</code> : select keys at random.</li>
|
233
|
+
<li><code>-mul <var>num</var></code> : specify the number of records for the mget command.</li>
|
234
|
+
<li><code>-shl <var>num</var></code> : use `tcrdbputshl' and specify the width.</li>
|
235
|
+
<li><code>-dai</code> : use `tcrdbaddint' instead of `tcrdbputcat'.</li>
|
236
|
+
<li><code>-dad</code> : use `tcrdbadddouble' instead of `tcrdbputcat'.</li>
|
237
|
+
<li><code>-ext <var>name</var></code> : call a script language extension function.</li>
|
238
|
+
<li><code>-xlr</code> : perform record locking.</li>
|
239
|
+
<li><code>-xlg</code> : perform global locking.</li>
|
240
|
+
<li><code>-exp <var>num</var></code> : specify the lifetime of expiration test.</li>
|
241
|
+
</ul>
|
242
|
+
|
243
|
+
<p>If the port number is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter. This command returns 0 on success, another on failure.</p>
|
244
|
+
|
245
|
+
<h3 id="clientprog_tcrmttest">tcrmttest</h3>
|
246
|
+
|
247
|
+
<p>The command `<code>tcrmttest</code>' is a utility for facility test under multi-thread situation. This command is used in the following format. `<var>host</var>' specifies the host name of the server. `<var>rnum</var>' specifies the number of iterations.</p>
|
248
|
+
|
249
|
+
|
250
|
+
<dl class="api">
|
251
|
+
<dt><code>tcrmttest write [-port <var>num</var>] [-tnum <var>num</var>] [-nr] [-rnd] [-ext <var>name</var>] <var>host</var> <var>rnum</var></code></dt>
|
252
|
+
<dd>Store records with keys of 8 bytes. They change as `00000001', `00000002'...</dd>
|
253
|
+
<dt><code>tcrmttest read [-port <var>num</var>] [-tnum <var>num</var>] [-mul <var>num</var>] <var>host</var></code></dt>
|
254
|
+
<dd>Retrieve all records of the database above.</dd>
|
255
|
+
<dt><code>tcrmttest remove [-port <var>num</var>] [-tnum <var>num</var>] <var>host</var></code></dt>
|
256
|
+
<dd>Remove all records of the database above.</dd>
|
257
|
+
</dl>
|
258
|
+
|
259
|
+
<p>Options feature the following.</p>
|
260
|
+
|
261
|
+
<ul class="options">
|
262
|
+
<li><code>-port <var>num</var></code> : specify the port number.</li>
|
263
|
+
<li><code>-tnum <var>num</var></code> : specify the number of running threads.</li>
|
264
|
+
<li><code>-nr</code> : use the function `tcrdbputnr' instead of `tcrdbput'.</li>
|
265
|
+
<li><code>-rnd</code> : select keys at random.</li>
|
266
|
+
<li><code>-ext <var>name</var></code> : call a script language extension function.</li>
|
267
|
+
<li><code>-mul <var>num</var></code> : specify the number of records for the mget command.</li>
|
268
|
+
</ul>
|
269
|
+
|
270
|
+
<p>If the port number is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter. This command returns 0 on success, another on failure.</p>
|
271
|
+
|
272
|
+
<h3 id="clientprog_tcrmgr">tcrmgr</h3>
|
273
|
+
|
274
|
+
<p>The command `<code>tcrmgr</code>' is a utility for test and debugging of the remote database API and its applications. `<var>host</var>' specifies the host name of the server. `<var>key</var>' specifies the key of a record. `<var>value</var>' specifies the value of a record. `<var>params</var>' specifies the tuning parameters. `<var>dpath</var>' specifies the destination file. `<var>func</var> specifies the name of the function. `<var>arg</var>' specifies the arguments of the function. `<var>file</var>' specifies the input file. `<var>upath</var>' specifies the update log directory. `<var>mhost</var>' specifies the host name of the replication master. `<var>url</var>' specifies the target URL.</p>
|
275
|
+
|
276
|
+
<dl class="api">
|
277
|
+
<dt><code>tcrmgr inform [-port <var>num</var>] [-st] <var>host</var></code></dt>
|
278
|
+
<dd>Print miscellaneous information to the standard output.</dd>
|
279
|
+
<dt><code>tcrmgr put [-port <var>num</var>] [-sx] [-sep <var>chr</var>] [-dk|-dc] <var>host</var> <var>key</var> <var>value</var></code></dt>
|
280
|
+
<dd>Store a record.</dd>
|
281
|
+
<dt><code>tcrmgr out [-port <var>num</var>] [-sx] [-sep <var>chr</var>] <var>host</var> <var>key</var></code></dt>
|
282
|
+
<dd>Remove a record.</dd>
|
283
|
+
<dt><code>tcrmgr get [-port <var>num</var>] [-sx] [-sep <var>chr</var>] [-px] [-pz] <var>host</var> <var>key</var></code></dt>
|
284
|
+
<dd>Print the value of a record.</dd>
|
285
|
+
<dt><code>tcrmgr mget [-port <var>num</var>] [-sx] [-sep <var>chr</var>] [-px] <var>host</var> [<var>key</var>...]</code></dt>
|
286
|
+
<dd>Print keys and values of multiple records.</dd>
|
287
|
+
<dt><code>tcrmgr list [-port <var>num</var>] [-sep <var>chr</var>] [-m <var>num</var>] [-pv] [-px] [-fm <var>str</var>] <var>host</var></code></dt>
|
288
|
+
<dd>Print keys of all records, separated by line feeds.</dd>
|
289
|
+
<dt><code>tcrmgr ext [-port <var>num</var>] [-xlr|-xlg] [-sx] [-sep <var>chr</var>] [-px] <var>host</var> <var>func</var> [<var>key</var> [<var>value</var>]]</code></dt>
|
290
|
+
<dd>Call a script language extension function.</dd>
|
291
|
+
<dt><code>tcrmgr sync [-port <var>num</var>] <var>host</var></code></dt>
|
292
|
+
<dd>Synchronize updated contents with the database file.</dd>
|
293
|
+
<dt><code>tcrmgr optimize [-port <var>num</var>] <var>host</var> [<var>params</var>]</code></dt>
|
294
|
+
<dd>Optimize the database file.</dd>
|
295
|
+
<dt><code>tcrmgr vanish [-port <var>num</var>] <var>host</var></code></dt>
|
296
|
+
<dd>Remove all records.</dd>
|
297
|
+
<dt><code>tcrmgr copy [-port <var>num</var>] <var>host</var> <var>dpath</var></code></dt>
|
298
|
+
<dd>Copy the database file.</dd>
|
299
|
+
<dt><code>tcrmgr misc [-port <var>num</var>] [-mnu] [-sx] [-sep <var>chr</var>] [-px] <var>host</var> <var>func</var> [<var>arg</var>...]</code></dt>
|
300
|
+
<dd>Call a versatile function for miscellaneous operations.</dd>
|
301
|
+
<dt><code>tcrmgr importtsv [-port <var>num</var>] [-nr] [-sc] <var>host</var> [<var>file</var>]</code></dt>
|
302
|
+
<dd>Store records of TSV in each line of a file.</dd>
|
303
|
+
<dt><code>tcrmgr restore [-port <var>num</var>] [-ts <var>num</var>] [-rcc] <var>host</var> <var>upath</var></code></dt>
|
304
|
+
<dd>Restore the database with update log.</dd>
|
305
|
+
<dt><code>tcrmgr setmst [-port <var>num</var>] [-mport <var>num</var>] [-ts <var>num</var>] [-rcc] <var>host</var> [<var>mhost</var>]</code></dt>
|
306
|
+
<dd>Set the replication master.</dd>
|
307
|
+
<dt><code>tcrmgr repl [-port <var>num</var>] [-ts <var>num</var>] [-sid <var>num</var>] [-ph] <var>host</var></code></dt>
|
308
|
+
<dd>Replicate the update log.</dd>
|
309
|
+
<dt><code>tcrmgr http [-ah <var>name</var> <var>value</var>] [-ih] <var>url</var></code></dt>
|
310
|
+
<dd>Fetch the resource of a URL by HTTP.</dd>
|
311
|
+
<dt><code>tcrmgr version</code></dt>
|
312
|
+
<dd>Print the version information of Tokyo Tyrant.</dd>
|
313
|
+
</dl>
|
314
|
+
|
315
|
+
<p>Options feature the following.</p>
|
316
|
+
|
317
|
+
<ul class="options">
|
318
|
+
<li><code>-port <var>num</var></code> : specify the port number.</li>
|
319
|
+
<li><code>-st</code> : print miscellaneous status data.</li>
|
320
|
+
<li><code>-sx</code> : input data is evaluated as a hexadecimal data string.</li>
|
321
|
+
<li><code>-sep <var>chr</var></code> : specify the separator of the input data.</li>
|
322
|
+
<li><code>-dk</code> : use the function `tcrdbputkeep' instead of `tcrdbput'.</li>
|
323
|
+
<li><code>-dc</code> : use the function `tcrdbputcat' instead of `tcrdbput'.</li>
|
324
|
+
<li><code>-px</code> : output data is converted into a hexadecimal data string.</li>
|
325
|
+
<li><code>-pz</code> : do not append line feed at the end of the output.</li>
|
326
|
+
<li><code>-m <var>num</var></code> : specify the maximum number of the output.</li>
|
327
|
+
<li><code>-pv</code> : print values of records also.</li>
|
328
|
+
<li><code>-fm <var>str</var></code> : specify the prefix of keys.</li>
|
329
|
+
<li><code>-xlr</code> : perform record locking.</li>
|
330
|
+
<li><code>-xlg</code> : perform global locking.</li>
|
331
|
+
<li><code>-mnu</code> : omit the update log.</li>
|
332
|
+
<li><code>-nr</code> : use the function `tcrdbputnr' instead of `tcrdbput'.</li>
|
333
|
+
<li><code>-sc</code> : normalize keys as lower cases.</li>
|
334
|
+
<li><code>-mport <var>num</var></code> : specify the port number of the replication master.</li>
|
335
|
+
<li><code>-ts <var>num</var></code> : specify the beginning time stamp.</li>
|
336
|
+
<li><code>-rcc</code> : check consistency of replication.</li>
|
337
|
+
<li><code>-sid <var>num</var></code> : specify the self server ID.</li>
|
338
|
+
<li><code>-ph</code> : print human-readable data.</li>
|
339
|
+
<li><code>-ah <var>name</var> <var>value</var></code> : add a request header.</li>
|
340
|
+
<li><code>-ih</code> : output response headers also.</li>
|
341
|
+
</ul>
|
342
|
+
|
343
|
+
<p>If the port number is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter. This command returns 0 on success, another on failure.</p>
|
344
|
+
|
345
|
+
<hr />
|
346
|
+
|
347
|
+
<h2 id="tcrdbapi">Remote Database API</h2>
|
348
|
+
|
349
|
+
<p>Remote database is a set of interfaces to use an abstract database of Tokyo Cabinet, mediated by a server of Tokyo Tyrant. See `<code>tcrdb.h</code>' for entire specification.</p>
|
350
|
+
|
351
|
+
<h3 id="clientprog_description">Description</h3>
|
352
|
+
|
353
|
+
<p>To use the remote database API, include `<code>tcrdb.h</code>' and related standard header files. Usually, write the following description near the front of a source file.</p>
|
354
|
+
|
355
|
+
<dl>
|
356
|
+
<dt><code>#include <tcrdb.h></code></dt>
|
357
|
+
<dt><code>#include <stdlib.h></code></dt>
|
358
|
+
<dt><code>#include <stdbool.h></code></dt>
|
359
|
+
<dt><code>#include <stdint.h></code></dt>
|
360
|
+
</dl>
|
361
|
+
|
362
|
+
<p>Objects whose type is pointer to `<code>TCRDB</code>' are used to handle remote databases. A remote database object is created with the function `<code>tcrdbnew</code>' and is deleted with the function `<code>tcrdbdel</code>'. To avoid memory leak, it is important to delete every object when it is no longer in use.</p>
|
363
|
+
|
364
|
+
<p>Before operations to store or retrieve records, it is necessary to connect the remote database object to the server. The function `<code>tcrdbopen</code>' is used to open a database connection and the function `<code>tcrdbclose</code>' is used to close the connection.</p>
|
365
|
+
|
366
|
+
<h3 id="tcrdbapi_api">API</h3>
|
367
|
+
|
368
|
+
<p>The function `tcrdberrmsg' is used in order to get the message string corresponding to an error code.</p>
|
369
|
+
|
370
|
+
<dl class="api">
|
371
|
+
<dt><code>const char *tcrdberrmsg(int <var>ecode</var>);</code></dt>
|
372
|
+
<dd>`<var>ecode</var>' specifies the error code.</dd>
|
373
|
+
<dd>The return value is the message string of the error code.</dd>
|
374
|
+
</dl>
|
375
|
+
|
376
|
+
<p>The function `tcrdbnew' is used in order to create a remote database object.</p>
|
377
|
+
|
378
|
+
<dl class="api">
|
379
|
+
<dt><code>TCRDB *tcrdbnew(void);</code></dt>
|
380
|
+
<dd>The return value is the new remote database object.</dd>
|
381
|
+
</dl>
|
382
|
+
|
383
|
+
<p>The function `tcrdbdel' is used in order to delete a remote database object.</p>
|
384
|
+
|
385
|
+
<dl class="api">
|
386
|
+
<dt><code>void tcrdbdel(TCRDB *<var>rdb</var>);</code></dt>
|
387
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
388
|
+
</dl>
|
389
|
+
|
390
|
+
<p>The function `tcrdbecode' is used in order to get the last happened error code of a remote database object.</p>
|
391
|
+
|
392
|
+
<dl class="api">
|
393
|
+
<dt><code>int tcrdbecode(TCRDB *<var>rdb</var>);</code></dt>
|
394
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
395
|
+
<dd>The return value is the last happened error code.</dd>
|
396
|
+
<dd>The following error code is defined: `TTESUCCESS' for success, `TTEINVALID' for invalid operation, `TTENOHOST' for host not found, `TTEREFUSED' for connection refused, `TTESEND' for send error, `TTERECV' for recv error, `TTEKEEP' for existing record, `TTENOREC' for no record found, `TTEMISC' for miscellaneous error.</dd>
|
397
|
+
</dl>
|
398
|
+
|
399
|
+
<p>The function `tcrdbtune' is used in order to set the tuning parameters of a hash database object.</p>
|
400
|
+
|
401
|
+
<dl class="api">
|
402
|
+
<dt><code>bool tcrdbtune(TCRDB *<var>rdb</var>, double <var>timeout</var>, int <var>opts</var>);</code></dt>
|
403
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
404
|
+
<dd>`<var>timeout</var>' specifies the timeout of each query in seconds. If it is not more than 0, the timeout is not specified.</dd>
|
405
|
+
<dd>`<var>opts</var>' specifies options by bitwise-or: `RDBTRECON' specifies that the connection is recovered automatically when it is disconnected.</dd>
|
406
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
407
|
+
<dd>Note that the tuning parameters should be set before the database is opened.</dd>
|
408
|
+
</dl>
|
409
|
+
|
410
|
+
<p>The function `tcrdbopen' is used in order to open a remote database.</p>
|
411
|
+
|
412
|
+
<dl class="api">
|
413
|
+
<dt><code>bool tcrdbopen(TCRDB *<var>rdb</var>, const char *<var>host</var>, int <var>port</var>);</code></dt>
|
414
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
415
|
+
<dd>`<var>host</var>' specifies the name or the address of the server.</dd>
|
416
|
+
<dd>`<var>port</var>' specifies the port number. If it is not more than 0, UNIX domain socket is used and the path of the socket file is specified by the host parameter.</dd>
|
417
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
418
|
+
</dl>
|
419
|
+
|
420
|
+
<p>The function `tcrdbopen2' is used in order to open a remote database with a simple server expression.</p>
|
421
|
+
|
422
|
+
<dl class="api">
|
423
|
+
<dt><code>bool tcrdbopen2(TCRDB *<var>rdb</var>, const char *<var>expr</var>);</code></dt>
|
424
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
425
|
+
<dd>`<var>expr</var>' specifies the simple server expression. It is composed of two substrings separated by ":". The former field specifies the name or the address of the server. The latter field specifies the port number. If the latter field is omitted, the default port number is specified.</dd>
|
426
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
427
|
+
</dl>
|
428
|
+
|
429
|
+
<p>The function `tcrdbclose' is used in order to close a remote database object.</p>
|
430
|
+
|
431
|
+
<dl class="api">
|
432
|
+
<dt><code>bool tcrdbclose(TCRDB *<var>rdb</var>);</code></dt>
|
433
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
434
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
435
|
+
</dl>
|
436
|
+
|
437
|
+
<p>The function `tcrdbput' is used in order to store a record into a remote database object.</p>
|
438
|
+
|
439
|
+
<dl class="api">
|
440
|
+
<dt><code>bool tcrdbput(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, const void *<var>vbuf</var>, int <var>vsiz</var>);</code></dt>
|
441
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
442
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
443
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
444
|
+
<dd>`<var>vbuf</var>' specifies the pointer to the region of the value.</dd>
|
445
|
+
<dd>`<var>vsiz</var>' specifies the size of the region of the value.</dd>
|
446
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
447
|
+
<dd>If a record with the same key exists in the database, it is overwritten.</dd>
|
448
|
+
</dl>
|
449
|
+
|
450
|
+
<p>The function `tcrdbput2' is used in order to store a string record into a remote object.</p>
|
451
|
+
|
452
|
+
<dl class="api">
|
453
|
+
<dt><code>bool tcrdbput2(TCRDB *<var>rdb</var>, const char *<var>kstr</var>, const char *<var>vstr</var>);</code></dt>
|
454
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
455
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
456
|
+
<dd>`<var>vstr</var>' specifies the string of the value.</dd>
|
457
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
458
|
+
<dd>If a record with the same key exists in the database, it is overwritten.</dd>
|
459
|
+
</dl>
|
460
|
+
|
461
|
+
<p>The function `tcrdbputkeep' is used in order to store a new record into a remote database object.</p>
|
462
|
+
|
463
|
+
<dl class="api">
|
464
|
+
<dt><code>bool tcrdbputkeep(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, const void *<var>vbuf</var>, int <var>vsiz</var>);</code></dt>
|
465
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
466
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
467
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
468
|
+
<dd>`<var>vbuf</var>' specifies the pointer to the region of the value.</dd>
|
469
|
+
<dd>`<var>vsiz</var>' specifies the size of the region of the value.</dd>
|
470
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
471
|
+
<dd>If a record with the same key exists in the database, this function has no effect.</dd>
|
472
|
+
</dl>
|
473
|
+
|
474
|
+
<p>The function `tcrdbputkeep2' is used in order to store a new string record into a remote database object.</p>
|
475
|
+
|
476
|
+
<dl class="api">
|
477
|
+
<dt><code>bool tcrdbputkeep2(TCRDB *<var>rdb</var>, const char *<var>kstr</var>, const char *<var>vstr</var>);</code></dt>
|
478
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
479
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
480
|
+
<dd>`<var>vstr</var>' specifies the string of the value.</dd>
|
481
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
482
|
+
<dd>If a record with the same key exists in the database, this function has no effect.</dd>
|
483
|
+
</dl>
|
484
|
+
|
485
|
+
<p>The function `tcrdbputcat' is used in order to concatenate a value at the end of the existing record in a remote database object.</p>
|
486
|
+
|
487
|
+
<dl class="api">
|
488
|
+
<dt><code>bool tcrdbputcat(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, const void *<var>vbuf</var>, int <var>vsiz</var>);</code></dt>
|
489
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
490
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
491
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
492
|
+
<dd>`<var>vbuf</var>' specifies the pointer to the region of the value.</dd>
|
493
|
+
<dd>`<var>vsiz</var>' specifies the size of the region of the value.</dd>
|
494
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
495
|
+
<dd>If there is no corresponding record, a new record is created.</dd>
|
496
|
+
</dl>
|
497
|
+
|
498
|
+
<p>The function `tcrdbputcat2' is used in order to concatenate a string value at the end of the existing record in a remote database object.</p>
|
499
|
+
|
500
|
+
<dl class="api">
|
501
|
+
<dt><code>bool tcrdbputcat2(TCRDB *<var>rdb</var>, const char *<var>kstr</var>, const char *<var>vstr</var>);</code></dt>
|
502
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
503
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
504
|
+
<dd>`<var>vstr</var>' specifies the string of the value.</dd>
|
505
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
506
|
+
<dd>If there is no corresponding record, a new record is created.</dd>
|
507
|
+
</dl>
|
508
|
+
|
509
|
+
<p>The function `tcrdbputshl' is used in order to concatenate a value at the end of the existing record and shift it to the left.</p>
|
510
|
+
|
511
|
+
<dl class="api">
|
512
|
+
<dt><code>bool tcrdbputshl(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, const void *<var>vbuf</var>, int <var>vsiz</var>, int <var>width</var>);</code></dt>
|
513
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
514
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
515
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
516
|
+
<dd>`<var>vbuf</var>' specifies the pointer to the region of the value.</dd>
|
517
|
+
<dd>`<var>vsiz</var>' specifies the size of the region of the value.</dd>
|
518
|
+
<dd>`<var>width</var>' specifies the width of the record.</dd>
|
519
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
520
|
+
<dd>If there is no corresponding record, a new record is created.</dd>
|
521
|
+
</dl>
|
522
|
+
|
523
|
+
<p>The function `tcrdbputshl2' is used in order to concatenate a string value at the end of the existing record and shift it to the left.</p>
|
524
|
+
|
525
|
+
<dl class="api">
|
526
|
+
<dt><code>bool tcrdbputshl2(TCRDB *<var>rdb</var>, const char *<var>kstr</var>, const char *<var>vstr</var>, int <var>width</var>);</code></dt>
|
527
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
528
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
529
|
+
<dd>`<var>vstr</var>' specifies the string of the value.</dd>
|
530
|
+
<dd>`<var>width</var>' specifies the width of the record.</dd>
|
531
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
532
|
+
<dd>If there is no corresponding record, a new record is created.</dd>
|
533
|
+
</dl>
|
534
|
+
|
535
|
+
<p>The function `tcrdbputnr' is used in order to store a record into a remote database object without response from the server.</p>
|
536
|
+
|
537
|
+
<dl class="api">
|
538
|
+
<dt><code>bool tcrdbputnr(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, const void *<var>vbuf</var>, int <var>vsiz</var>);</code></dt>
|
539
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
540
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
541
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
542
|
+
<dd>`<var>vbuf</var>' specifies the pointer to the region of the value.</dd>
|
543
|
+
<dd>`<var>vsiz</var>' specifies the size of the region of the value.</dd>
|
544
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
545
|
+
<dd>If a record with the same key exists in the database, it is overwritten.</dd>
|
546
|
+
</dl>
|
547
|
+
|
548
|
+
<p>The function `tcrdbputnr2' is used in order to store a string record into a remote object without response from the server.</p>
|
549
|
+
|
550
|
+
<dl class="api">
|
551
|
+
<dt><code>bool tcrdbputnr2(TCRDB *<var>rdb</var>, const char *<var>kstr</var>, const char *<var>vstr</var>);</code></dt>
|
552
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
553
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
554
|
+
<dd>`<var>vstr</var>' specifies the string of the value.</dd>
|
555
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
556
|
+
<dd>If a record with the same key exists in the database, it is overwritten.</dd>
|
557
|
+
</dl>
|
558
|
+
|
559
|
+
<p>The function `tcrdbout' is used in order to remove a record of a remote database object.</p>
|
560
|
+
|
561
|
+
<dl class="api">
|
562
|
+
<dt><code>bool tcrdbout(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>);</code></dt>
|
563
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
564
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
565
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
566
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
567
|
+
</dl>
|
568
|
+
|
569
|
+
<p>The function `tcrdbout2' is used in order to remove a string record of a remote database object.</p>
|
570
|
+
|
571
|
+
<dl class="api">
|
572
|
+
<dt><code>bool tcrdbout2(TCRDB *<var>rdb</var>, const char *<var>kstr</var>);</code></dt>
|
573
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
574
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
575
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
576
|
+
</dl>
|
577
|
+
|
578
|
+
<p>The function `tcrdbget' is used in order to retrieve a record in a remote database object.</p>
|
579
|
+
|
580
|
+
<dl class="api">
|
581
|
+
<dt><code>void *tcrdbget(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, int *<var>sp</var>);</code></dt>
|
582
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
583
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
584
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
585
|
+
<dd>`<var>sp</var>' specifies the pointer to the variable into which the size of the region of the return value is assigned.</dd>
|
586
|
+
<dd>If successful, the return value is the pointer to the region of the value of the corresponding record. `NULL' is returned if no record corresponds.</dd>
|
587
|
+
<dd>Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.</dd>
|
588
|
+
</dl>
|
589
|
+
|
590
|
+
<p>The function `tcrdbget2' is used in order to retrieve a string record in a remote database object.</p>
|
591
|
+
|
592
|
+
<dl class="api">
|
593
|
+
<dt><code>char *tcrdbget2(TCRDB *<var>rdb</var>, const char *<var>kstr</var>);</code></dt>
|
594
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
595
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
596
|
+
<dd>If successful, the return value is the string of the value of the corresponding record. `NULL' is returned if no record corresponds.</dd>
|
597
|
+
<dd>Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.</dd>
|
598
|
+
</dl>
|
599
|
+
|
600
|
+
<p>The function `tcrdbget3' is used in order to retrieve records in a remote database object.</p>
|
601
|
+
|
602
|
+
<dl class="api">
|
603
|
+
<dt><code>bool tcrdbget3(TCRDB *<var>rdb</var>, TCMAP *<var>recs</var>);</code></dt>
|
604
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
605
|
+
<dd>`<var>recs</var>' specifies a map object containing the retrieval keys. As a result of this function, keys existing in the database have the corresponding values and keys not existing in the database are removed.</dd>
|
606
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
607
|
+
</dl>
|
608
|
+
|
609
|
+
<p>The function `tcrdbvsiz' is used in order to get the size of the value of a record in a remote database object.</p>
|
610
|
+
|
611
|
+
<dl class="api">
|
612
|
+
<dt><code>int tcrdbvsiz(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>);</code></dt>
|
613
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
614
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
615
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
616
|
+
<dd>If successful, the return value is the size of the value of the corresponding record, else, it is -1.</dd>
|
617
|
+
</dl>
|
618
|
+
|
619
|
+
<p>The function `tcrdbvsiz2' is used in order to get the size of the value of a string record in a remote database object.</p>
|
620
|
+
|
621
|
+
<dl class="api">
|
622
|
+
<dt><code>int tcrdbvsiz2(TCRDB *<var>rdb</var>, const char *<var>kstr</var>);</code></dt>
|
623
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
624
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
625
|
+
<dd>If successful, the return value is the size of the value of the corresponding record, else, it is -1.</dd>
|
626
|
+
</dl>
|
627
|
+
|
628
|
+
<p>The function `tcrdbiterinit' is used in order to initialize the iterator of a remote database object.</p>
|
629
|
+
|
630
|
+
<dl class="api">
|
631
|
+
<dt><code>bool tcrdbiterinit(TCRDB *<var>rdb</var>);</code></dt>
|
632
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
633
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
634
|
+
<dd>The iterator is used in order to access the key of every record stored in a database.</dd>
|
635
|
+
</dl>
|
636
|
+
|
637
|
+
<p>The function `tcrdbiternext' is used in order to get the next key of the iterator of a remote database object.</p>
|
638
|
+
|
639
|
+
<dl class="api">
|
640
|
+
<dt><code>void *tcrdbiternext(TCRDB *<var>rdb</var>, int *<var>sp</var>);</code></dt>
|
641
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
642
|
+
<dd>`<var>sp</var>' specifies the pointer to the variable into which the size of the region of the return value is assigned.</dd>
|
643
|
+
<dd>If successful, the return value is the pointer to the region of the next key, else, it is `NULL'. `NULL' is returned when no record is to be get out of the iterator.</dd>
|
644
|
+
<dd>Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use. The iterator can be updated by multiple connections and then it is not assured that every record is traversed.</dd>
|
645
|
+
</dl>
|
646
|
+
|
647
|
+
<p>The function `tcrdbiternext2' is used in order to get the next key string of the iterator of a remote database object.</p>
|
648
|
+
|
649
|
+
<dl class="api">
|
650
|
+
<dt><code>char *tcrdbiternext2(TCRDB *<var>rdb</var>);</code></dt>
|
651
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
652
|
+
<dd>If successful, the return value is the string of the next key, else, it is `NULL'. `NULL' is returned when no record is to be get out of the iterator.</dd>
|
653
|
+
<dd>Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use. The iterator can be updated by multiple connections and then it is not assured that every record is traversed.</dd>
|
654
|
+
</dl>
|
655
|
+
|
656
|
+
<p>The function `tcrdbfwmkeys' is used in order to get forward matching keys in a remote database object.</p>
|
657
|
+
|
658
|
+
<dl class="api">
|
659
|
+
<dt><code>TCLIST *tcrdbfwmkeys(TCRDB *<var>rdb</var>, const void *<var>pbuf</var>, int <var>psiz</var>, int <var>max</var>);</code></dt>
|
660
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
661
|
+
<dd>`<var>pbuf</var>' specifies the pointer to the region of the prefix.</dd>
|
662
|
+
<dd>`<var>psiz</var>' specifies the size of the region of the prefix.</dd>
|
663
|
+
<dd>`<var>max</var>' specifies the maximum number of keys to be fetched. If it is negative, no limit is specified.</dd>
|
664
|
+
<dd>The return value is a list object of the corresponding keys. This function does never fail. It returns an empty list even if no key corresponds.</dd>
|
665
|
+
<dd>Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.</dd>
|
666
|
+
</dl>
|
667
|
+
|
668
|
+
<p>The function `tcrdbfwmkeys2' is used in order to get forward matching string keys in a remote database object.</p>
|
669
|
+
|
670
|
+
<dl class="api">
|
671
|
+
<dt><code>TCLIST *tcrdbfwmkeys2(TCRDB *<var>rdb</var>, const char *<var>pstr</var>, int <var>max</var>);</code></dt>
|
672
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
673
|
+
<dd>`<var>pstr</var>' specifies the string of the prefix.</dd>
|
674
|
+
<dd>`<var>max</var>' specifies the maximum number of keys to be fetched. If it is negative, no limit is specified.</dd>
|
675
|
+
<dd>The return value is a list object of the corresponding keys. This function does never fail. It returns an empty list even if no key corresponds.</dd>
|
676
|
+
<dd>Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.</dd>
|
677
|
+
</dl>
|
678
|
+
|
679
|
+
<p>The function `tcrdbaddint' is used in order to add an integer to a record in a remote database object.</p>
|
680
|
+
|
681
|
+
<dl class="api">
|
682
|
+
<dt><code>int tcrdbaddint(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, int <var>num</var>);</code></dt>
|
683
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
684
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
685
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
686
|
+
<dd>`<var>num</var>' specifies the additional value.</dd>
|
687
|
+
<dd>If successful, the return value is the summation value, else, it is `INT_MIN'.</dd>
|
688
|
+
<dd>If the corresponding record exists, the value is treated as an integer and is added to. If no record corresponds, a new record of the additional value is stored.</dd>
|
689
|
+
</dl>
|
690
|
+
|
691
|
+
<p>The function `tcrdbadddouble' is used in order to add a real number to a record in a remote database object.</p>
|
692
|
+
|
693
|
+
<dl class="api">
|
694
|
+
<dt><code>double tcrdbadddouble(TCRDB *<var>rdb</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, double <var>num</var>);</code></dt>
|
695
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
696
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
697
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
698
|
+
<dd>`<var>num</var>' specifies the additional value.</dd>
|
699
|
+
<dd>If successful, the return value is the summation value, else, it is Not-a-Number.</dd>
|
700
|
+
<dd>If the corresponding record exists, the value is treated as a real number and is added to. If no record corresponds, a new record of the additional value is stored.</dd>
|
701
|
+
</dl>
|
702
|
+
|
703
|
+
<p>The function `tcrdbext' is used in order to call a function of the script language extension.</p>
|
704
|
+
|
705
|
+
<dl class="api">
|
706
|
+
<dt><code>void *tcrdbext(TCRDB *<var>rdb</var>, const char *<var>name</var>, int <var>opts</var>, const void *<var>kbuf</var>, int <var>ksiz</var>, const void *<var>vbuf</var>, int <var>vsiz</var>, int *<var>sp</var>);</code></dt>
|
707
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
708
|
+
<dd>`<var>name</var>' specifies the function name.</dd>
|
709
|
+
<dd>`<var>opts</var>' specifies options by bitwise-or: `RDBXOLCKREC' for record locking, `RDBXOLCKGLB' for global locking.</dd>
|
710
|
+
<dd>`<var>kbuf</var>' specifies the pointer to the region of the key.</dd>
|
711
|
+
<dd>`<var>ksiz</var>' specifies the size of the region of the key.</dd>
|
712
|
+
<dd>`<var>vbuf</var>' specifies the pointer to the region of the value.</dd>
|
713
|
+
<dd>`<var>vsiz</var>' specifies the size of the region of the value.</dd>
|
714
|
+
<dd>`<var>sp</var>' specifies the pointer to the variable into which the size of the region of the return value is assigned.</dd>
|
715
|
+
<dd>If successful, the return value is the pointer to the region of the value of the response. `NULL' is returned on failure.</dd>
|
716
|
+
<dd>Because an additional zero code is appended at the end of the region of the return value, the return value can be treated as a character string. Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.</dd>
|
717
|
+
</dl>
|
718
|
+
|
719
|
+
<p>The function `tcrdbext2' is used in order to call a function of the script language extension with string parameters.</p>
|
720
|
+
|
721
|
+
<dl class="api">
|
722
|
+
<dt><code>char *tcrdbext2(TCRDB *<var>rdb</var>, const char *<var>name</var>, int <var>opts</var>, const char *<var>kstr</var>, const char *<var>vstr</var>);</code></dt>
|
723
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
724
|
+
<dd>`<var>name</var>' specifies the function name.</dd>
|
725
|
+
<dd>`<var>opts</var>' specifies options by bitwise-or: `RDBXOLCKREC' for record locking, `RDBXOLCKGLB' for global locking.</dd>
|
726
|
+
<dd>`<var>kstr</var>' specifies the string of the key.</dd>
|
727
|
+
<dd>`<var>vstr</var>' specifies the string of the value.</dd>
|
728
|
+
<dd>If successful, the return value is the string of the value of the response. `NULL' is returned on failure.</dd>
|
729
|
+
<dd>Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.</dd>
|
730
|
+
</dl>
|
731
|
+
|
732
|
+
<p>The function `tcrdbsync' is used in order to synchronize updated contents of a remote database object with the file and the device.</p>
|
733
|
+
|
734
|
+
<dl class="api">
|
735
|
+
<dt><code>bool tcrdbsync(TCRDB *<var>rdb</var>);</code></dt>
|
736
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
737
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
738
|
+
</dl>
|
739
|
+
|
740
|
+
<p>The function `tcrdboptimize' is used in order to optimize the storage of a remove database object.</p>
|
741
|
+
|
742
|
+
<dl class="api">
|
743
|
+
<dt><code>bool tcrdboptimize(TCRDB *<var>rdb</var>, const char *<var>params</var>);</code></dt>
|
744
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
745
|
+
<dd>`<var>params</var>' specifies the string of the tuning parameters. If it is `NULL', it is not used.</dd>
|
746
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
747
|
+
</dl>
|
748
|
+
|
749
|
+
<p>The function `tcrdbvanish' is used in order to remove all records of a remote database object.</p>
|
750
|
+
|
751
|
+
<dl class="api">
|
752
|
+
<dt><code>bool tcrdbvanish(TCRDB *<var>rdb</var>);</code></dt>
|
753
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
754
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
755
|
+
</dl>
|
756
|
+
|
757
|
+
<p>The function `tcrdbcopy' is used in order to copy the database file of a remote database object.</p>
|
758
|
+
|
759
|
+
<dl class="api">
|
760
|
+
<dt><code>bool tcrdbcopy(TCRDB *<var>rdb</var>, const char *<var>path</var>);</code></dt>
|
761
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
762
|
+
<dd>`<var>path</var>' specifies the path of the destination file. If it begins with `@', the trailing substring is executed as a command line.</dd>
|
763
|
+
<dd>If successful, the return value is true, else, it is false. False is returned if the executed command returns non-zero code.</dd>
|
764
|
+
<dd>The database file is assured to be kept synchronized and not modified while the copying or executing operation is in progress. So, this function is useful to create a backup file of the database file.</dd>
|
765
|
+
</dl>
|
766
|
+
|
767
|
+
<p>The function `tcrdbrestore' is used in order to restore the database file of a remote database object from the update log.</p>
|
768
|
+
|
769
|
+
<dl class="api">
|
770
|
+
<dt><code>bool tcrdbrestore(TCRDB *<var>rdb</var>, const char *<var>path</var>, uint64_t <var>ts</var>, int <var>opts</var>);</code></dt>
|
771
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
772
|
+
<dd>`<var>path</var>' specifies the path of the update log directory.</dd>
|
773
|
+
<dd>`<var>opts</var>' specifies options by bitwise-or: `RDBROCHKCON' for consistency checking.</dd>
|
774
|
+
<dd>`<var>ts</var>' specifies the beginning time stamp in microseconds.</dd>
|
775
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
776
|
+
</dl>
|
777
|
+
|
778
|
+
<p>The function `tcrdbsetmst' is used in order to set the replication master of a remote database object.</p>
|
779
|
+
|
780
|
+
<dl class="api">
|
781
|
+
<dt><code>bool tcrdbsetmst(TCRDB *<var>rdb</var>, const char *<var>host</var>, int <var>port</var>, uint64_t <var>ts</var>, int <var>opts</var>);</code></dt>
|
782
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
783
|
+
<dd>`<var>host</var>' specifies the name or the address of the server. If it is `NULL', replication of the database is disabled.</dd>
|
784
|
+
<dd>`<var>port</var>' specifies the port number.</dd>
|
785
|
+
<dd>`<var>ts</var>' specifies the beginning timestamp in microseconds.</dd>
|
786
|
+
<dd>`<var>opts</var>' specifies options by bitwise-or: `RDBROCHKCON' for consistency checking.</dd>
|
787
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
788
|
+
</dl>
|
789
|
+
|
790
|
+
<p>The function `tcrdbsetmst2' is used in order to set the replication master of a remote database object with a simple server expression.</p>
|
791
|
+
|
792
|
+
<dl class="api">
|
793
|
+
<dt><code>bool tcrdbsetmst2(TCRDB *<var>rdb</var>, const char *<var>expr</var>, uint64_t <var>ts</var>, int <var>opts</var>);</code></dt>
|
794
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
795
|
+
<dd>`<var>expr</var>' specifies the simple server expression. It is composed of two substrings separated by ":". The former field specifies the name or the address of the server. The latter field specifies the port number. If the latter field is omitted, the default port number is specified.</dd>
|
796
|
+
<dd>`<var>ts</var>' specifies the beginning timestamp in microseconds.</dd>
|
797
|
+
<dd>`<var>opts</var>' specifies options by bitwise-or: `RDBROCHKCON' for consistency checking.</dd>
|
798
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
799
|
+
</dl>
|
800
|
+
|
801
|
+
<p>The function `tcrdbrnum' is used in order to get the number of records of a remote database object.</p>
|
802
|
+
|
803
|
+
<dl class="api">
|
804
|
+
<dt><code>uint64_t tcrdbrnum(TCRDB *<var>rdb</var>);</code></dt>
|
805
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
806
|
+
<dd>The return value is the number of records or 0 if the object does not connect to any database server.</dd>
|
807
|
+
</dl>
|
808
|
+
|
809
|
+
<p>The function `tcrdbsize' is used in order to get the size of the database of a remote database object.</p>
|
810
|
+
|
811
|
+
<dl class="api">
|
812
|
+
<dt><code>uint64_t tcrdbsize(TCRDB *<var>rdb</var>);</code></dt>
|
813
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
814
|
+
<dd>The return value is the size of the database or 0 if the object does not connect to any database server.</dd>
|
815
|
+
</dl>
|
816
|
+
|
817
|
+
<p>The function `tcrdbstat' is used in order to get the status string of the database of a remote database object.</p>
|
818
|
+
|
819
|
+
<dl class="api">
|
820
|
+
<dt><code>char *tcrdbstat(TCRDB *<var>rdb</var>);</code></dt>
|
821
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
822
|
+
<dd>The return value is the status message of the database or `NULL' if the object does not connect to any database server. The message format is TSV. The first field of each line means the parameter name and the second field means the value.</dd>
|
823
|
+
<dd>Because the region of the return value is allocated with the `malloc' call, it should be released with the `free' call when it is no longer in use.</dd>
|
824
|
+
</dl>
|
825
|
+
|
826
|
+
<p>The function `tcrdbmisc' is used in order to call a versatile function for miscellaneous operations of a remote database object.</p>
|
827
|
+
|
828
|
+
<dl class="api">
|
829
|
+
<dt><code>TCLIST *tcrdbmisc(TCRDB *<var>rdb</var>, const char *<var>name</var>, int <var>opts</var>, const TCLIST *<var>args</var>);</code></dt>
|
830
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
831
|
+
<dd>`<var>name</var>' specifies the name of the function. All databases support "put", "out", "get", "putlist", "outlist", and "getlist". "put" is to store a record. It receives a key and a value, and returns an empty list. "out" is to remove a record. It receives a key, and returns an empty list. "get" is to retrieve a record. It receives a key, and returns a list of the values. "putlist" is to store records. It receives keys and values one after the other, and returns an empty list. "outlist" is to remove records. It receives keys, and returns an empty list. "getlist" is to retrieve records. It receives keys, and returns keys and values of corresponding records one after the other.</dd>
|
832
|
+
<dd>`<var>opts</var>' specifies options by bitwise-or: `RDBMONOULOG' for omission of the update log.</dd>
|
833
|
+
<dd>`<var>args</var>' specifies a list object containing arguments.</dd>
|
834
|
+
<dd>If successful, the return value is a list object of the result. `NULL' is returned on failure.</dd>
|
835
|
+
<dd>Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.</dd>
|
836
|
+
</dl>
|
837
|
+
|
838
|
+
<h3 id="tcrdbapi_apitbl">API of the Table Extension</h3>
|
839
|
+
|
840
|
+
<p>The function `tcrdbtblput' is used in order to store a record into a remote database object.</p>
|
841
|
+
|
842
|
+
<dl class="api">
|
843
|
+
<dt><code>bool tcrdbtblput(TCRDB *<var>rdb</var>, const void *<var>pkbuf</var>, int <var>pksiz</var>, TCMAP *<var>cols</var>);</code></dt>
|
844
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
845
|
+
<dd>`<var>pkbuf</var>' specifies the pointer to the region of the primary key.</dd>
|
846
|
+
<dd>`<var>pksiz</var>' specifies the size of the region of the primary key.</dd>
|
847
|
+
<dd>`<var>cols</var>' specifies a map object containing columns.</dd>
|
848
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
849
|
+
<dd>If a record with the same key exists in the database, it is overwritten.</dd>
|
850
|
+
</dl>
|
851
|
+
|
852
|
+
<p>The function `tcrdbtblputkeep' is used in order to store a new record into a remote database object.</p>
|
853
|
+
|
854
|
+
<dl class="api">
|
855
|
+
<dt><code>bool tcrdbtblputkeep(TCRDB *<var>rdb</var>, const void *<var>pkbuf</var>, int <var>pksiz</var>, TCMAP *<var>cols</var>);</code></dt>
|
856
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
857
|
+
<dd>`<var>pkbuf</var>' specifies the pointer to the region of the primary key.</dd>
|
858
|
+
<dd>`<var>pksiz</var>' specifies the size of the region of the primary key.</dd>
|
859
|
+
<dd>`<var>cols</var>' specifies a map object containing columns.</dd>
|
860
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
861
|
+
<dd>If a record with the same key exists in the database, this function has no effect.</dd>
|
862
|
+
</dl>
|
863
|
+
|
864
|
+
<p>The function `tcrdbtblputcat' is used in order to concatenate columns of the existing record in a remote database object.</p>
|
865
|
+
|
866
|
+
<dl class="api">
|
867
|
+
<dt><code>bool tcrdbtblputcat(TCRDB *<var>rdb</var>, const void *<var>pkbuf</var>, int <var>pksiz</var>, TCMAP *<var>cols</var>);</code></dt>
|
868
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
869
|
+
<dd>`<var>pkbuf</var>' specifies the pointer to the region of the primary key.</dd>
|
870
|
+
<dd>`<var>pksiz</var>' specifies the size of the region of the primary key.</dd>
|
871
|
+
<dd>`<var>cols</var>' specifies a map object containing columns.</dd>
|
872
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
873
|
+
<dd>If there is no corresponding record, a new record is created.</dd>
|
874
|
+
</dl>
|
875
|
+
|
876
|
+
<p>The function `tcrdbtblout' is used in order to remove a record of a remote database object.</p>
|
877
|
+
|
878
|
+
<dl class="api">
|
879
|
+
<dt><code>bool tcrdbtblout(TCRDB *<var>rdb</var>, const void *<var>pkbuf</var>, int <var>pksiz</var>);</code></dt>
|
880
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
881
|
+
<dd>`<var>pkbuf</var>' specifies the pointer to the region of the primary key.</dd>
|
882
|
+
<dd>`<var>pksiz</var>' specifies the size of the region of the primary key.</dd>
|
883
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
884
|
+
</dl>
|
885
|
+
|
886
|
+
<p>The function `tcrdbtblget' is used in order to retrieve a record in a remote database object.</p>
|
887
|
+
|
888
|
+
<dl class="api">
|
889
|
+
<dt><code>TCMAP *tcrdbtblget(TCRDB *<var>rdb</var>, const void *<var>pkbuf</var>, int <var>pksiz</var>);</code></dt>
|
890
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
891
|
+
<dd>`<var>pkbuf</var>' specifies the pointer to the region of the primary key.</dd>
|
892
|
+
<dd>`<var>pksiz</var>' specifies the size of the region of the primary key.</dd>
|
893
|
+
<dd>If successful, the return value is a map object of the columns of the corresponding record. `NULL' is returned if no record corresponds.</dd>
|
894
|
+
<dd>Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use.</dd>
|
895
|
+
</dl>
|
896
|
+
|
897
|
+
<p>The function `tcrdbtblsetindex' is used in order to set a column index to a remote database object.</p>
|
898
|
+
|
899
|
+
<dl class="api">
|
900
|
+
<dt><code>bool tcrdbtblsetindex(TCRDB *<var>rdb</var>, const char *<var>name</var>, int <var>type</var>);</code></dt>
|
901
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
902
|
+
<dd>`<var>name</var>' specifies the name of a column. If the name of an existing index is specified, the index is rebuilt. An empty string means the primary key.</dd>
|
903
|
+
<dd>`<var>type</var>' specifies the index type: `RDBITLEXICAL' for lexical string, `RDBITDECIMAL' for decimal string, `RDBITTOKEN' for token inverted index, `RDBITQGRAM' for q-gram inverted index. If it is `RDBITOPT', the index is optimized. If it is `RDBITVOID', the index is removed. If `RDBITKEEP' is added by bitwise-or and the index exists, this function merely returns failure.</dd>
|
904
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
905
|
+
</dl>
|
906
|
+
|
907
|
+
<p>The function `tcrdbtblgenuid' is used in order to generate a unique ID number of a remote database object.</p>
|
908
|
+
|
909
|
+
<dl class="api">
|
910
|
+
<dt><code>int64_t tcrdbtblgenuid(TCRDB *<var>rdb</var>);</code></dt>
|
911
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
912
|
+
<dd>The return value is the new unique ID number or -1 on failure.</dd>
|
913
|
+
</dl>
|
914
|
+
|
915
|
+
<p>The function `tcrdbqrynew' is used in order to create a query object.</p>
|
916
|
+
|
917
|
+
<dl class="api">
|
918
|
+
<dt><code>RDBQRY *tcrdbqrynew(TCRDB *<var>rdb</var>);</code></dt>
|
919
|
+
<dd>`<var>rdb</var>' specifies the remote database object.</dd>
|
920
|
+
<dd>The return value is the new query object.</dd>
|
921
|
+
</dl>
|
922
|
+
|
923
|
+
<p>The function `tcrdbqrydel' is used in order to delete a query object.</p>
|
924
|
+
|
925
|
+
<dl class="api">
|
926
|
+
<dt><code>void tcrdbqrydel(RDBQRY *<var>qry</var>);</code></dt>
|
927
|
+
<dd>`<var>qry</var>' specifies the query object.</dd>
|
928
|
+
</dl>
|
929
|
+
|
930
|
+
<p>The function `tcrdbqryaddcond' is used in order to add a narrowing condition to a query object.</p>
|
931
|
+
|
932
|
+
<dl class="api">
|
933
|
+
<dt><code>void tcrdbqryaddcond(RDBQRY *<var>qry</var>, const char *<var>name</var>, int <var>op</var>, const char *<var>expr</var>);</code></dt>
|
934
|
+
<dd>`<var>qry</var>' specifies the query object.</dd>
|
935
|
+
<dd>`<var>name</var>' specifies the name of a column. An empty string means the primary key.</dd>
|
936
|
+
<dd>`<var>op</var>' specifies an operation type: `RDBQCSTREQ' for string which is equal to the expression, `RDBQCSTRINC' for string which is included in the expression, `RDBQCSTRBW' for string which begins with the expression, `RDBQCSTREW' for string which ends with the expression, `RDBQCSTRAND' for string which includes all tokens in the expression, `RDBQCSTROR' for string which includes at least one token in the expression, `RDBQCSTROREQ' for string which is equal to at least one token in the expression, `RDBQCSTRRX' for string which matches regular expressions of the expression, `RDBQCNUMEQ' for number which is equal to the expression, `RDBQCNUMGT' for number which is greater than the expression, `RDBQCNUMGE' for number which is greater than or equal to the expression, `RDBQCNUMLT' for number which is less than the expression, `RDBQCNUMLE' for number which is less than or equal to the expression, `RDBQCNUMBT' for number which is between two tokens of the expression, `RDBQCNUMOREQ' for number which is equal to at least one token in the expression, `RDBQCFTSPH' for full-text search with the phrase of the expression, `RDBQCFTSAND' for full-text search with all tokens in the expression, `RDBQCFTSOR' for full-text search with at least one token in the expression, `RDBQCFTSEX' for full-text search with the compound expression. All operations can be flagged by bitwise-or: `RDBQCNEGATE' for negation, `RDBQCNOIDX' for using no index.</dd>
|
937
|
+
<dd>`<var>expr</var>' specifies an operand exression.</dd>
|
938
|
+
</dl>
|
939
|
+
|
940
|
+
<p>The function `tcrdbqrysetorder' is used in order to set the order of a query object.</p>
|
941
|
+
|
942
|
+
<dl class="api">
|
943
|
+
<dt><code>void tcrdbqrysetorder(RDBQRY *<var>qry</var>, const char *<var>name</var>, int <var>type</var>);</code></dt>
|
944
|
+
<dd>`<var>qry</var>' specifies the query object.</dd>
|
945
|
+
<dd>`<var>name</var>' specifies the name of a column. An empty string means the primary key.</dd>
|
946
|
+
<dd>`<var>type</var>' specifies the order type: `RDBQOSTRASC' for string ascending, `RDBQOSTRDESC' for string descending, `RDBQONUMASC' for number ascending, `RDBQONUMDESC' for number descending.</dd>
|
947
|
+
</dl>
|
948
|
+
|
949
|
+
<p>The function `tcrdbqrysetlimit' is used in order to set the limit number of records of the result of a query object.</p>
|
950
|
+
|
951
|
+
<dl class="api">
|
952
|
+
<dt><code>void tcrdbqrysetlimit(RDBQRY *<var>qry</var>, int <var>max</var>, int <var>skip</var>);</code></dt>
|
953
|
+
<dd>`<var>qry</var>' specifies the query object.</dd>
|
954
|
+
<dd>`<var>max</var>' specifies the maximum number of records of the result. If it is negative, no limit is specified.</dd>
|
955
|
+
<dd>`<var>skip</var>' specifies the number of skipped records of the result. If it is not more than 0, no record is skipped.</dd>
|
956
|
+
</dl>
|
957
|
+
|
958
|
+
<p>The function `tcrdbqrysearch' is used in order to execute the search of a query object.</p>
|
959
|
+
|
960
|
+
<dl class="api">
|
961
|
+
<dt><code>TCLIST *tcrdbqrysearch(RDBQRY *<var>qry</var>);</code></dt>
|
962
|
+
<dd>`<var>qry</var>' specifies the query object.</dd>
|
963
|
+
<dd>The return value is a list object of the primary keys of the corresponding records. This function does never fail. It returns an empty list even if no record corresponds.</dd>
|
964
|
+
<dd>Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.</dd>
|
965
|
+
</dl>
|
966
|
+
|
967
|
+
<p>The function `tcrdbqrysearchout' is used in order to remove each record corresponding to a query object.</p>
|
968
|
+
|
969
|
+
<dl class="api">
|
970
|
+
<dt><code>bool tcrdbqrysearchout(RDBQRY *<var>qry</var>);</code></dt>
|
971
|
+
<dd>`<var>qry</var>' specifies the query object of the database.</dd>
|
972
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
973
|
+
</dl>
|
974
|
+
|
975
|
+
<p>The function `tcrdbqrysearchget' is used in order to get records corresponding to the search of a query object.</p>
|
976
|
+
|
977
|
+
<dl class="api">
|
978
|
+
<dt><code>TCLIST *tcrdbqrysearchget(RDBQRY *<var>qry</var>);</code></dt>
|
979
|
+
<dd>`<var>qry</var>' specifies the query object.</dd>
|
980
|
+
<dd>The return value is a list object of zero separated columns of the corresponding records.</dd>
|
981
|
+
<dd>This function does never fail. It returns an empty list even if no record corresponds. Each element of the list can be treated with the function `tcrdbqryrescols'. Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.</dd>
|
982
|
+
</dl>
|
983
|
+
|
984
|
+
<p>The function `tcrdbqryrescols' is used in order to get columns of a record in a search result.</p>
|
985
|
+
|
986
|
+
<dl class="api">
|
987
|
+
<dt><code>TCMAP *tcrdbqryrescols(TCLIST *<var>res</var>, int <var>index</var>);</code></dt>
|
988
|
+
<dd>`<var>res</var>' specifies a list of zero separated columns of the search result.</dd>
|
989
|
+
<dd>`<var>index</var>' the index of a element of the search result.</dd>
|
990
|
+
<dd>The return value is a map object containing columns.</dd>
|
991
|
+
<dd>Because the object of the return value is created with the function `tcmapnew', it should be deleted with the function `tcmapdel' when it is no longer in use.</dd>
|
992
|
+
</dl>
|
993
|
+
|
994
|
+
<p>The function `tcrdbqrysearchcount' is used in order to get the count of corresponding records of a query object.</p>
|
995
|
+
|
996
|
+
<dl class="api">
|
997
|
+
<dt><code>int tcrdbqrysearchcount(RDBQRY *<var>qry</var>);</code></dt>
|
998
|
+
<dd>`<var>qry</var>' specifies the query object.</dd>
|
999
|
+
<dd>The return value is the count of corresponding records or 0 on failure.</dd>
|
1000
|
+
</dl>
|
1001
|
+
|
1002
|
+
<p>The function `tcrdbqryhint' is used in order to get the hint string of a query object.</p>
|
1003
|
+
|
1004
|
+
<dl class="api">
|
1005
|
+
<dt><code>const char *tcrdbqryhint(RDBQRY *<var>qry</var>);</code></dt>
|
1006
|
+
<dd>`<var>qry</var>' specifies the query object.</dd>
|
1007
|
+
<dd>The return value is the hint string.</dd>
|
1008
|
+
<dd>This function should be called after the query execution by `tcrdbqrysearch' and so on. The region of the return value is overwritten when this function is called again.</dd>
|
1009
|
+
</dl>
|
1010
|
+
|
1011
|
+
<p>The function `tcrdbmetasearch' is used in order to retrieve records with multiple query objects and get the set of the result.</p>
|
1012
|
+
|
1013
|
+
<dl class="api">
|
1014
|
+
<dt><code>TCLIST *tcrdbmetasearch(RDBQRY **<var>qrys</var>, int <var>num</var>, int <var>type</var>);</code></dt>
|
1015
|
+
<dd>`<var>qrys</var>' specifies an array of the query objects.</dd>
|
1016
|
+
<dd>`<var>num</var>' specifies the number of elements of the array.</dd>
|
1017
|
+
<dd>`<var>type</var>' specifies a set operation type: `RDBMSUNION' for the union set, `RDBMSISECT' for the intersection set, `RDBMSDIFF' for the difference set.</dd>
|
1018
|
+
<dd>The return value is a list object of the primary keys of the corresponding records. This function does never fail. It returns an empty list even if no record corresponds.</dd>
|
1019
|
+
<dd>If the first query object has the order setting, the result array is sorted by the order. Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.</dd>
|
1020
|
+
</dl>
|
1021
|
+
|
1022
|
+
<p>The function `tcrdbparasearch' is used in order to search records for multiple servers in parallel.</p>
|
1023
|
+
|
1024
|
+
<dl class="api">
|
1025
|
+
<dt><code>TCLIST *tcrdbparasearch(RDBQRY **<var>qrys</var>, int <var>num</var>);</code></dt>
|
1026
|
+
<dd>`<var>qrys</var>' specifies an array of the query objects.</dd>
|
1027
|
+
<dd>`<var>num</var>' specifies the number of elements of the array.</dd>
|
1028
|
+
<dd>The return value is a list object of zero separated columns of the corresponding records.</dd>
|
1029
|
+
<dd>This function does never fail. It returns an empty list even if no record corresponds. Each element of the list can be treated with the function `tcrdbqryrescols'. Because the object of the return value is created with the function `tclistnew', it should be deleted with the function `tclistdel' when it is no longer in use.</dd>
|
1030
|
+
</dl>
|
1031
|
+
|
1032
|
+
<h3 id="tcrdbapi_example">Example Code</h3>
|
1033
|
+
|
1034
|
+
<p>The following code is an example to use a remote database.</p>
|
1035
|
+
|
1036
|
+
<pre>#include <tcrdb.h>
|
1037
|
+
#include <stdlib.h>
|
1038
|
+
#include <stdbool.h>
|
1039
|
+
#include <stdint.h>
|
1040
|
+
|
1041
|
+
int main(int argc, char **argv){
|
1042
|
+
|
1043
|
+
TCRDB *rdb;
|
1044
|
+
int ecode;
|
1045
|
+
char *value;
|
1046
|
+
|
1047
|
+
/* create the object */
|
1048
|
+
rdb = tcrdbnew();
|
1049
|
+
|
1050
|
+
/* connect to the server */
|
1051
|
+
if(!tcrdbopen(rdb, "localhost", 1978)){
|
1052
|
+
ecode = tcrdbecode(rdb);
|
1053
|
+
fprintf(stderr, "open error: %s\n", tcrdberrmsg(ecode));
|
1054
|
+
}
|
1055
|
+
|
1056
|
+
/* store records */
|
1057
|
+
if(!tcrdbput2(rdb, "foo", "hop") ||
|
1058
|
+
!tcrdbput2(rdb, "bar", "step") ||
|
1059
|
+
!tcrdbput2(rdb, "baz", "jump")){
|
1060
|
+
ecode = tcrdbecode(rdb);
|
1061
|
+
fprintf(stderr, "put error: %s\n", tcrdberrmsg(ecode));
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
/* retrieve records */
|
1065
|
+
value = tcrdbget2(rdb, "foo");
|
1066
|
+
if(value){
|
1067
|
+
printf("%s\n", value);
|
1068
|
+
free(value);
|
1069
|
+
} else {
|
1070
|
+
ecode = tcrdbecode(rdb);
|
1071
|
+
fprintf(stderr, "get error: %s\n", tcrdberrmsg(ecode));
|
1072
|
+
}
|
1073
|
+
|
1074
|
+
/* close the connection */
|
1075
|
+
if(!tcrdbclose(rdb)){
|
1076
|
+
ecode = tcrdbecode(rdb);
|
1077
|
+
fprintf(stderr, "close error: %s\n", tcrdberrmsg(ecode));
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
/* delete the object */
|
1081
|
+
tcrdbdel(rdb);
|
1082
|
+
|
1083
|
+
return 0;
|
1084
|
+
}
|
1085
|
+
</pre>
|
1086
|
+
|
1087
|
+
<p>The following code is an example to use a remote database with the table extension.</p>
|
1088
|
+
|
1089
|
+
<pre>#include <tcrdb.h>
|
1090
|
+
#include <stdlib.h>
|
1091
|
+
#include <stdbool.h>
|
1092
|
+
#include <stdint.h>
|
1093
|
+
|
1094
|
+
int main(int argc, char **argv){
|
1095
|
+
|
1096
|
+
TCRDB *rdb;
|
1097
|
+
int ecode, pksiz, i, rsiz;
|
1098
|
+
char pkbuf[256];
|
1099
|
+
const char *rbuf, *name;
|
1100
|
+
TCMAP *cols;
|
1101
|
+
RDBQRY *qry;
|
1102
|
+
TCLIST *res;
|
1103
|
+
|
1104
|
+
/* create the object */
|
1105
|
+
rdb = tcrdbnew();
|
1106
|
+
|
1107
|
+
/* connect to the server */
|
1108
|
+
if(!tcrdbopen(rdb, "localhost", 1978)){
|
1109
|
+
ecode = tcrdbecode(rdb);
|
1110
|
+
fprintf(stderr, "open error: %s\n", tcrdberrmsg(ecode));
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
/* store a record */
|
1114
|
+
pksiz = sprintf(pkbuf, "%ld", (long)tcrdbtblgenuid(rdb));
|
1115
|
+
cols = tcmapnew3("name", "mikio", "age", "30", "lang", "ja,en,c", NULL);
|
1116
|
+
if(!tcrdbtblput(rdb, pkbuf, pksiz, cols)){
|
1117
|
+
ecode = tcrdbecode(rdb);
|
1118
|
+
fprintf(stderr, "put error: %s\n", tcrdberrmsg(ecode));
|
1119
|
+
}
|
1120
|
+
tcmapdel(cols);
|
1121
|
+
|
1122
|
+
/* store a record in a naive way */
|
1123
|
+
pksiz = sprintf(pkbuf, "12345");
|
1124
|
+
cols = tcmapnew();
|
1125
|
+
tcmapput2(cols, "name", "falcon");
|
1126
|
+
tcmapput2(cols, "age", "31");
|
1127
|
+
tcmapput2(cols, "lang", "ja");
|
1128
|
+
if(!tcrdbtblput(rdb, pkbuf, pksiz, cols)){
|
1129
|
+
ecode = tcrdbecode(rdb);
|
1130
|
+
fprintf(stderr, "put error: %s\n", tcrdberrmsg(ecode));
|
1131
|
+
}
|
1132
|
+
tcmapdel(cols);
|
1133
|
+
|
1134
|
+
/* search for records */
|
1135
|
+
qry = tcrdbqrynew(rdb);
|
1136
|
+
tcrdbqryaddcond(qry, "age", RDBQCNUMGE, "20");
|
1137
|
+
tcrdbqryaddcond(qry, "lang", RDBQCSTROR, "ja,en");
|
1138
|
+
tcrdbqrysetorder(qry, "name", RDBQOSTRASC);
|
1139
|
+
tcrdbqrysetlimit(qry, 10, 0);
|
1140
|
+
res = tcrdbqrysearch(qry);
|
1141
|
+
for(i = 0; i < tclistnum(res); i++){
|
1142
|
+
rbuf = tclistval(res, i, &rsiz);
|
1143
|
+
cols = tcrdbtblget(rdb, rbuf, rsiz);
|
1144
|
+
if(cols){
|
1145
|
+
printf("%s", rbuf);
|
1146
|
+
tcmapiterinit(cols);
|
1147
|
+
while((name = tcmapiternext2(cols)) != NULL){
|
1148
|
+
printf("\t%s\t%s", name, tcmapget2(cols, name));
|
1149
|
+
}
|
1150
|
+
printf("\n");
|
1151
|
+
tcmapdel(cols);
|
1152
|
+
}
|
1153
|
+
}
|
1154
|
+
tclistdel(res);
|
1155
|
+
tcrdbqrydel(qry);
|
1156
|
+
|
1157
|
+
/* close the connection */
|
1158
|
+
if(!tcrdbclose(rdb)){
|
1159
|
+
ecode = tcrdbecode(rdb);
|
1160
|
+
fprintf(stderr, "close error: %s\n", tcrdberrmsg(ecode));
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
/* delete the object */
|
1164
|
+
tcrdbdel(rdb);
|
1165
|
+
|
1166
|
+
return 0;
|
1167
|
+
}
|
1168
|
+
</pre>
|
1169
|
+
|
1170
|
+
<h3 id="tcrdbapi_uselib">How to Use the Library</h3>
|
1171
|
+
|
1172
|
+
<p>The API of C is available by programs conforming to the C89 (ANSI C) standard or the C99 standard. As the header files of Tokyo Tyrant are provided as `<code>tcrdb.h</code>', applications should include it to use the API. As the library is provided as `<code>libtokyotyrant.a</code>' and `<code>libtokyotyrant.so</code>' and they depends `<code>libtokyocabinet.so</code>', `<code>libz.so</code>', `<code>libbz2.so</code>', `<code>libresolv.so</code>', `<code>libnsl.so</code>', `<code>libdl.so</code>', `<code>librt.so</code>', `<code>libpthread.so</code>', `<code>libm.so</code>', and `<code>libc.so</code>', linker options `<code>-ltokyotyrant</code>', `<code>-ltokyocabinet</code>', `<code>-lz</code>', `<code>-lbz2</code>', `<code>-lresolv</code>', `<code>-lnsl</code>', `<code>-ldl</code>', `<code>-lrt</code>', `<code>-lpthread</code>', `<code>-lm</code>', and `<code>-lc</code>' are required for build command. A typical build command is the following.</p>
|
1173
|
+
|
1174
|
+
<pre>gcc -I/usr/local/include tt_example.c -o tt_example \
|
1175
|
+
-L/usr/local/lib -ltokyotyrant -ltokyocabinet -lz -lbz2 \
|
1176
|
+
-lresolv -lnsl -ldl -lrt -lpthread -lm -lc
|
1177
|
+
</pre>
|
1178
|
+
|
1179
|
+
<p>You can also use Tokyo Tyrant in programs written in C++. Because each header is wrapped in C linkage (`<code>extern "C"</code>' block), you can simply include them into your C++ programs.</p>
|
1180
|
+
|
1181
|
+
<hr />
|
1182
|
+
|
1183
|
+
<h2 id="luaext">Lua Extension</h2>
|
1184
|
+
|
1185
|
+
<p>The database server can starts reading a Lua script file by the `<code>-ext</code>' option. Clients can call functions defined in the script file by the `<code>tcrdbext</code>' function of the remote database API.</p>
|
1186
|
+
|
1187
|
+
<h3 id="luaext_userfunc">User-defined Functions</h3>
|
1188
|
+
|
1189
|
+
<p>You can define some arbitrary functions in the script file. Each function receives two string parameters of the key and the value. The return value is sent back to the client. If the function returns `nil', the server send the error code to the client.</p>
|
1190
|
+
|
1191
|
+
<p>Two kinds of locking options are provided to `<code>tcrdbext</code>'. One is global locking which means that only one thread can operate the function at the same time. The other is record locking which means that only one thread can operate the record of the specified key at the same time.</p>
|
1192
|
+
|
1193
|
+
<p>Note that instances of Lua interpreter are handled separately by each native thread. Because global variables of Lua are not useful to share some data among native threads or sessions, shared data should be handled in the database or by the stash functions.</p>
|
1194
|
+
|
1195
|
+
<h3 id="luaext_builtinfunc">Built-in Functions</h3>
|
1196
|
+
|
1197
|
+
<p>The following build-in functions for database operations are available in user defined functions. The type of `key' and `value' parameters should be string or number. If number is given, it is converted as decimal string.</p>
|
1198
|
+
|
1199
|
+
<dl>
|
1200
|
+
<dt><code>_eval(<var>chunk</var>)</code></dt>
|
1201
|
+
<dd>Evaluate a Lua chunk in each native thread.</dd>
|
1202
|
+
<dd>`<var>chunk</var>' specifies the Lua chunk string.</dd>
|
1203
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1204
|
+
<dt><code>_log(<var>message</var>, <var>level</var>)</code></dt>
|
1205
|
+
<dd>Print a message into the server log.</dd>
|
1206
|
+
<dd>`<var>message</var>' specifies the message string.</dd>
|
1207
|
+
<dd>`<var>level</var>' specifies the log level; 0 for debug, 1 for information, 2 for error, 3 for system. It can be omitted and the default value is 1.</dd>
|
1208
|
+
<dt><code>_put(<var>key</var>, <var>value</var>)</code></dt>
|
1209
|
+
<dd>Store a record.</dd>
|
1210
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1211
|
+
<dd>`<var>value</var>' specifies the value.</dd>
|
1212
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1213
|
+
<dt><code>_putkeep(<var>key</var>, <var>value</var>)</code></dt>
|
1214
|
+
<dd>Store a new record.</dd>
|
1215
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1216
|
+
<dd>`<var>value</var>' specifies the value.</dd>
|
1217
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1218
|
+
<dt><code>_putcat(<var>key</var>, <var>value</var>)</code></dt>
|
1219
|
+
<dd>Concatenate a value at the end of the existing record.</dd>
|
1220
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1221
|
+
<dd>`<var>value</var>' specifies the value.</dd>
|
1222
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1223
|
+
<dt><code>_out(<var>key</var>)</code></dt>
|
1224
|
+
<dd>Remove a record.</dd>
|
1225
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1226
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1227
|
+
<dt><code>_get(<var>key</var>)</code></dt>
|
1228
|
+
<dd>Retrieve a record.</dd>
|
1229
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1230
|
+
<dd>If successful, the return value is the value of the corresponding record. `nil' is returned if no record corresponds.</dd>
|
1231
|
+
<dt><code>_vsiz(<var>key</var>)</code></dt>
|
1232
|
+
<dd>Get the size of the value of a record.</dd>
|
1233
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1234
|
+
<dd>If successful, the return value is the size of the value of the corresponding record, else, it is -1.</dd>
|
1235
|
+
<dt><code>_iterinit()</code></dt>
|
1236
|
+
<dd>Initialize the iterator.</dd>
|
1237
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1238
|
+
<dt><code>_iternext()</code></dt>
|
1239
|
+
<dd>Get the next key of the iterator.</dd>
|
1240
|
+
<dd>If successful, the return value is the next key, else, it is `nil'. `nil' is returned when no record is to be get out of the iterator.</dd>
|
1241
|
+
<dt><code>_fwmkeys(<var>prefix</var>, <var>max</var>)</code></dt>
|
1242
|
+
<dd>Get forward matching keys.</dd>
|
1243
|
+
<dd>The return value an array of the keys of the corresponding records. This function does never fail. It returns an empty array even if no record corresponds.</dd>
|
1244
|
+
<dt><code>_addint(<var>key</var>, <var>value</var>)</code></dt>
|
1245
|
+
<dd>Add an integer to a record.</dd>
|
1246
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1247
|
+
<dd>`<var>value</var>' specifies the value.</dd>
|
1248
|
+
<dd>If successful, the return value is the summation value, else, it is `nil'.</dd>
|
1249
|
+
<dt><code>_adddouble(<var>key</var>, <var>value</var>)</code></dt>
|
1250
|
+
<dd>Add a real number to a record.</dd>
|
1251
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1252
|
+
<dd>`<var>value</var>' specifies the value.</dd>
|
1253
|
+
<dd>If successful, the return value is the summation value, else, it is `nil'.</dd>
|
1254
|
+
<dt><code>_vanish()</code></dt>
|
1255
|
+
<dd>Remove all records.</dd>
|
1256
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1257
|
+
<dt><code>_rnum()</code></dt>
|
1258
|
+
<dd>Get the number of records.</dd>
|
1259
|
+
<dd>The return value is the number of records.</dd>
|
1260
|
+
<dt><code>_size()</code></dt>
|
1261
|
+
<dd>Get the size of the database file.</dd>
|
1262
|
+
<dd>The return value is the size of the database file.</dd>
|
1263
|
+
<dt><code>_misc(<var>name</var>, <var>args</var>, ...)</code></dt>
|
1264
|
+
<dd>Call a versatile function for miscellaneous operations.</dd>
|
1265
|
+
<dd>`<var>name</var>' specifies the name of the function. If it begins with "$", the update log is omitted.</dd>
|
1266
|
+
<dd>`<var>args</var>' specifies an array of arguments.</dd>
|
1267
|
+
<dd>If successful, the return value is an array of the result. `nil' is returned on failure.</dd>
|
1268
|
+
<dt><code>_foreach(<var>func</var>)</code></dt>
|
1269
|
+
<dd>Process each record atomically.</dd>
|
1270
|
+
<dd>`<var>func</var>' the iterator function called for each record. It receives two parameters of the key and the value, and returns true to continue iteration or false to stop iteration.</dd>
|
1271
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1272
|
+
<dt><code>_mapreduce(<var>mapper</var>, <var>reducer</var>, <var>keys</var>)</code></dt>
|
1273
|
+
<dd>Perform operations based on MapReduce.</dd>
|
1274
|
+
<dd>`<var>mapper</var>' specifies the mapper function. It is called for each target record and receives the key, the value, and the function to emit the mapped records. The emitter function receives a key and a value. The mapper function should return true normally or false on failure.</dd>
|
1275
|
+
<dd>`<var>reducer</var>' specifies the reducer function. It is called for each record generated by sorting emitted records by keys, and receives the key and an array of values. The reducer function should return true normally or false on failure.</dd>
|
1276
|
+
<dd>`<var>keys</var>' specifies the keys of target records. If it is not defined, every record in the database is processed.</dd>
|
1277
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1278
|
+
<dt><code>_stashput(<var>key</var>, <var>value</var>)</code></dt>
|
1279
|
+
<dd>Store a record into the stash.</dd>
|
1280
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1281
|
+
<dd>`<var>value</var>' specifies the value.</dd>
|
1282
|
+
<dd>The return value is always true.</dd>
|
1283
|
+
<dt><code>_stashout(<var>key</var>)</code></dt>
|
1284
|
+
<dd>Remove a record from the stash.</dd>
|
1285
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1286
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1287
|
+
<dt><code>_stashget(<var>key</var>)</code></dt>
|
1288
|
+
<dd>Retrieve a record in the stash.</dd>
|
1289
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1290
|
+
<dd>If successful, the return value is the value of the corresponding record. `nil' is returned if no record corresponds.</dd>
|
1291
|
+
<dt><code>_stashvanish()</code></dt>
|
1292
|
+
<dd>Remove all records of the stash.</dd>
|
1293
|
+
<dt><code>_stashforeach(<var>func</var>)</code></dt>
|
1294
|
+
<dd>Process each record atomically of the stash.</dd>
|
1295
|
+
<dd>`<var>func</var>' the iterator function called for each record. It receives two parameters of the key and the value, and returns true to continue iteration or false to stop iteration.</dd>
|
1296
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1297
|
+
<dt><code>_lock(<var>key</var>)</code></dt>
|
1298
|
+
<dd>Lock an arbitrary key.</dd>
|
1299
|
+
<dd>`<var>key</var>' specifies the key. The locked key should be unlocked in the same operation.</dd>
|
1300
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1301
|
+
<dt><code>_unlock(<var>key</var>)</code></dt>
|
1302
|
+
<dd>Unock an arbitrary key.</dd>
|
1303
|
+
<dd>`<var>key</var>' specifies the key.</dd>
|
1304
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1305
|
+
<dt><code>_pack(<var>format</var>, <var>ary</var>, ...)</code></dt>
|
1306
|
+
<dd>Serialize an array of numbers into a string.</dd>
|
1307
|
+
<dd>`<var>format</var>' specifies the format string. It should be composed of conversion characters; `c' for int8_t, `C' for uint8_t, `s' for int16_t, `S' for uint16_t, `i' for int32_t, `I' for uint32_t, `l' for int64_t, `L' for uint64_t, `f' for float, `d' for double, `n' for uint16_t in network byte order, `N' for uint32_t in network byte order, `M' for uint64_t in network byte order, and `w' for BER encoding. They can be trailed by a numeric expression standing for the iteration count or by `*' for the rest all iteration.</dd>
|
1308
|
+
<dd>`<var>ary</var>' specifies the array of numbers.</dd>
|
1309
|
+
<dd>The return value is the serialized string.</dd>
|
1310
|
+
<dt><code>_unpack(<var>format</var>, <var>str</var>)</code></dt>
|
1311
|
+
<dd>Deserialize a binary string into an array of numbers.</dd>
|
1312
|
+
<dd>`<var>format</var>' specifies the format string. It should be composed of conversion characters as with `_pack'.</dd>
|
1313
|
+
<dd>`<var>str</var>' specifies the binary string.</dd>
|
1314
|
+
<dd>The return value is the deserialized array.</dd>
|
1315
|
+
<dt><code>_split(<var>str</var>, <var>delims</var>)</code></dt>
|
1316
|
+
<dd>Split a string into substrings.</dd>
|
1317
|
+
<dd>`<var>str</var>' specifies the string.</dd>
|
1318
|
+
<dd>`<var>delims</var>' specifies a string including separator characters. If it is not defined, the zero code is specified.</dd>
|
1319
|
+
<dd>The return value is an array of substrings.</dd>
|
1320
|
+
<dt><code>_codec(<var>mode</var>, <var>str</var>)</code></dt>
|
1321
|
+
<dd>Encode or decode a string.</dd>
|
1322
|
+
<dd>`<var>mode</var>' specifies the encoding method; "url" for URL encoding, "~url" for URL decoding, "base" for Base64 encoding, "~base" for Base64 decoding, "hex" for hexadecimal encoding, "~hex" for hexadecimal decoding, "pack" for PackBits encoding, "~pack" for PackBits decoding, "tcbs" for TCBS encoding, "~tcbs" for TCBS decoding, "deflate" for Deflate encoding, "~deflate" for Deflate decoding, "gzip" for GZIP encoding, "~gzip" for GZIP decoding, "bzip" for BZIP2 encoding, "~bzip" for BZIP2 decoding, "xml" for XML escaping, "~xml" for XML unescaping.</dd>
|
1323
|
+
<dd>`<var>str</var>' specifies the string.</dd>
|
1324
|
+
<dd>The return value is the encoded or decoded string.</dd>
|
1325
|
+
<dt><code>_hash(<var>mode</var>, <var>str</var>)</code></dt>
|
1326
|
+
<dd>Get the hash value of a string.</dd>
|
1327
|
+
<dd>`<var>mode</var>' specifies the hash method; "md5" for MD5 in hexadecimal format, "md5raw" for MD5 in raw format, "crc32" for CRC32 checksum number.</dd>
|
1328
|
+
<dd>`<var>str</var>' specifies the string.</dd>
|
1329
|
+
<dd>The return value is the hash value.</dd>
|
1330
|
+
<dt><code>_bit(<var>mode</var>, <var>num</var>, <var>aux</var>)</code></dt>
|
1331
|
+
<dd>Perform bit operation of an integer.</dd>
|
1332
|
+
<dd>`<var>mode</var>' specifies the operator; "and" for bitwise-and operation, "or" for bitwise-or operation, "xor" for bitwise-xor operation, "not" for bitwise-not operation, "left" for left shift operation, "right" for right shift operation.</dd>
|
1333
|
+
<dd>`<var>num</var>' specifies the integer, which is treated as a 32-bit unsigned integer.</dd>
|
1334
|
+
<dd>`<var>aux</var>' specifies the auxiliary operand for some operators.</dd>
|
1335
|
+
<dd>The return value is the result value.</dd>
|
1336
|
+
<dt><code>_strstr(<var>str</var>, <var>pattern</var>, <var>alt</var>)</code></dt>
|
1337
|
+
<dd>Perform substring matching or replacement without evaluating any meta character.</dd>
|
1338
|
+
<dd>`<var>str</var>' specifies the source string.</dd>
|
1339
|
+
<dd>`<var>pattern</var>' specifies the matching pattern.</dd>
|
1340
|
+
<dd>`<var>alt</var>' specifies the alternative string corresponding for the pattern. If it is not defined, matching check is performed.</dd>
|
1341
|
+
<dd>If the alternative string is specified, the converted string is returned. If the alternative string is not specified, the index of the substring matching the given pattern or 0 is returned.</dd>
|
1342
|
+
<dt><code>_regex(<var>str</var>, <var>pattern</var>, <var>alt</var>)</code></dt>
|
1343
|
+
<dd>Perform pattern matching or replacement with regular expressions.</dd>
|
1344
|
+
<dd>`<var>str</var>' specifies the source string.</dd>
|
1345
|
+
<dd>`<var>pattern</var>' specifies the pattern of regular expressions.</dd>
|
1346
|
+
<dd>`<var>alt</var>' specifies the alternative string corresponding for the pattern. If it is not defined, matching check is performed.</dd>
|
1347
|
+
<dd>If the alternative string is specified, the converted string is returned. If the alternative string is not specified, the boolean value of whether the source string matches the pattern is returned.</dd>
|
1348
|
+
<dt><code>_ucs(<var>data</var>)</code></dt>
|
1349
|
+
<dd>Convert a UTF-8 string into a UCS-2 array or its inverse.</dd>
|
1350
|
+
<dd>`<var>data</var>' specifies the target data. If it is a string, convert it into a UCS-array. If it is an array, convert it into a UTF-8 string.</dd>
|
1351
|
+
<dd>The return value is the result data.</dd>
|
1352
|
+
<dt><code>_dist(<var>astr</var>, <var>bstr</var>, <var>isutf</var>)</code></dt>
|
1353
|
+
<dd>Calculate the edit distance of two UTF-8 strings.</dd>
|
1354
|
+
<dd>`<var>astr</var>' specifies a string.</dd>
|
1355
|
+
<dd>`<var>bstr</var>' specifies the other string.</dd>
|
1356
|
+
<dd>`<var>isutf</var>' specifies whether to calculate cost by Unicode character. If it is not defined, false is specified and calculate cost by ASCII character.</dd>
|
1357
|
+
<dd>The return value is the edit distance which is known as the Levenshtein distance.</dd>
|
1358
|
+
<dt><code>_isect(ary, ...)</code></dt>
|
1359
|
+
<dd>Calculate the intersection set of arrays.</dd>
|
1360
|
+
<dd>`<var>ary</var>' specifies the arrays. Arbitrary number of arrays can be specified as the parameter list.</dd>
|
1361
|
+
<dd>The return value is the array of the intersection set.</dd>
|
1362
|
+
<dt><code>_union(ary, ...)</code></dt>
|
1363
|
+
<dd>Calculate the union set of arrays.</dd>
|
1364
|
+
<dd>`<var>ary</var>' specifies the arrays. Arbitrary number of arrays can be specified as the parameter list.</dd>
|
1365
|
+
<dd>The return value is the array of the union set.</dd>
|
1366
|
+
<dt><code>_time()</code></dt>
|
1367
|
+
<dd>Get the time of day in seconds.</dd>
|
1368
|
+
<dd>The return value is the time of day in seconds. The accuracy is in microseconds.</dd>
|
1369
|
+
<dt><code>_sleep(<var>sec</var>)</code></dt>
|
1370
|
+
<dd>Suspend execution for the specified interval.</dd>
|
1371
|
+
<dd>`<var>sec</var>' specifies the interval in seconds.</dd>
|
1372
|
+
<dd>If successful, the return value is true, else, it is false.</dd>
|
1373
|
+
<dt><code>_stat(<var>path</var>)</code></dt>
|
1374
|
+
<dd>Get the status of a file.</dd>
|
1375
|
+
<dd>`<var>path</var>' specifies the path of the file.</dd>
|
1376
|
+
<dd>If successful, the return value is a table containing status, else, it is `nil'. There are keys of status name; "dev", "ino", "mode", "nlink", "uid", "gid", "rdev", "size", "blksize", "blocks", "atime", "mtime", "ctime", which have same meanings of the POSIX "stat" call. Additionally, "_regular" for whether the file is a regular file, "_directory" for whether the file is a directory, "_readable" for whether the file is readable by the process, "_writable" for whether the file is writable by the process, "_executable" for whether the file is executable by the process, "_realpath" for the real path of the file, are supported.</dd>
|
1377
|
+
<dt><code>_glob(<var>pattern</var>)</code></dt>
|
1378
|
+
<dd>Find pathnames matching a pattern.</dd>
|
1379
|
+
<dd>`<var>pattern</var>' specifies the matching pattern. "?" and "*" are meta characters.</dd>
|
1380
|
+
<dd>The return value is an array of matched paths. If no path is matched, an empty array is returned.</dd>
|
1381
|
+
<dt><code>_remove(<var>path</var>)</code></dt>
|
1382
|
+
<dd>Remove a file or a directory and its sub ones recursively.</dd>
|
1383
|
+
<dd>`<var>path</var>' specifies the path of the link.</dd>
|
1384
|
+
<dd>If successful, it is true, else, it is false.</dd>
|
1385
|
+
<dt><code>_mkdir(<var>path</var>)</code></dt>
|
1386
|
+
<dd>Create a directory.</dd>
|
1387
|
+
<dd>`<var>path</var>' specifies the path of the directory.</dd>
|
1388
|
+
<dd>If successful, it is true, else, it is false.</dd>
|
1389
|
+
</dl>
|
1390
|
+
|
1391
|
+
<p>Built-in functions, whose names start with "_", cannot be called directly by clients. When the server starts, the function `<code>_begin</code>' is called implicitly if it has been defined. When the server starts, the function `<code>_end</code>' is called implicitly if it has been defined.</p>
|
1392
|
+
|
1393
|
+
<p>The global variable `<code>_version</code>' contains the version information of the server. The global variable `<code>_pid</code>' contains the process ID. The global variable `<code>_sid</code>' contains the server ID. The global variable `<code>_thnum</code>' contains the number of native threads. The global variable `<code>_thid</code>' contains the ID number of each native thread.</p>
|
1394
|
+
|
1395
|
+
<h3 id="luaext_example">Example Code</h3>
|
1396
|
+
|
1397
|
+
<p>The following code is an example to increment the record value and store as a decimal number string. This function should be called with the record locking option to ensure atomicity.</p>
|
1398
|
+
|
1399
|
+
<pre>function incr(key, value)
|
1400
|
+
value = tonumber(value)
|
1401
|
+
if not value then
|
1402
|
+
return nil
|
1403
|
+
end
|
1404
|
+
local old = tonumber(_get(key))
|
1405
|
+
if old then
|
1406
|
+
value = value + old
|
1407
|
+
end
|
1408
|
+
if not _put(key, value) then
|
1409
|
+
return nil
|
1410
|
+
end
|
1411
|
+
return value
|
1412
|
+
end
|
1413
|
+
</pre>
|
1414
|
+
|
1415
|
+
<hr />
|
1416
|
+
|
1417
|
+
<h2 id="protocol">Protocol</h2>
|
1418
|
+
|
1419
|
+
<p>The protocol between the server and clients stands on TCP/IP. By default, the service port is bound to every address of the local host and the port number is 1978. Each session of the server and a client is composed of a request and a response. The server speaks three protocols at the same port.</p>
|
1420
|
+
|
1421
|
+
<h3 id="protocol_binary">Original Binary Protocol</h3>
|
1422
|
+
|
1423
|
+
<p>In the original binary protocol, requests are classified into the following commands. Structure of request and response is determined by the command. The byte order of integer in request and response is big endian.</p>
|
1424
|
+
|
1425
|
+
<dl class="api">
|
1426
|
+
<dt><code>put</code>: for the function `tcrdbput'</dt>
|
1427
|
+
<dd><dl>
|
1428
|
+
<dt>Request: <code>[magic:2][ksiz:4][vsiz:4][kbuf:*][vbuf:*]</code></dt>
|
1429
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x10</dd>
|
1430
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1431
|
+
<dd>A 32-bit integer standing for the length of the value</dd>
|
1432
|
+
<dd>Arbitrary data of the key</dd>
|
1433
|
+
<dd>Arbitrary data of the value</dd>
|
1434
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1435
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1436
|
+
</dl></dd>
|
1437
|
+
</dl>
|
1438
|
+
|
1439
|
+
<dl class="api">
|
1440
|
+
<dt><code>putkeep</code>: for the function `tcrdbputkeep'</dt>
|
1441
|
+
<dd><dl>
|
1442
|
+
<dt>Request: <code>[magic:2][ksiz:4][vsiz:4][kbuf:*][vbuf:*]</code></dt>
|
1443
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x11</dd>
|
1444
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1445
|
+
<dd>A 32-bit integer standing for the length of the value</dd>
|
1446
|
+
<dd>Arbitrary data of the key</dd>
|
1447
|
+
<dd>Arbitrary data of the value</dd>
|
1448
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1449
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1450
|
+
</dl></dd>
|
1451
|
+
</dl>
|
1452
|
+
|
1453
|
+
<dl class="api">
|
1454
|
+
<dt><code>putcat</code>: for the function `tcrdbputcat'</dt>
|
1455
|
+
<dd><dl>
|
1456
|
+
<dt>Request: <code>[magic:2][ksiz:4][vsiz:4][kbuf:*][vbuf:*]</code></dt>
|
1457
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x12</dd>
|
1458
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1459
|
+
<dd>A 32-bit integer standing for the length of the value</dd>
|
1460
|
+
<dd>Arbitrary data of the key</dd>
|
1461
|
+
<dd>Arbitrary data of the value</dd>
|
1462
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1463
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1464
|
+
</dl></dd>
|
1465
|
+
</dl>
|
1466
|
+
|
1467
|
+
<dl class="api">
|
1468
|
+
<dt><code>putshl</code>: for the function `tcrdbputshl'</dt>
|
1469
|
+
<dd><dl>
|
1470
|
+
<dt>Request: <code>[magic:2][ksiz:4][vsiz:4][width:4][kbuf:*][vbuf:*]</code></dt>
|
1471
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x13</dd>
|
1472
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1473
|
+
<dd>A 32-bit integer standing for the length of the value</dd>
|
1474
|
+
<dd>A 32-bit integer standing for the width</dd>
|
1475
|
+
<dd>Arbitrary data of the key</dd>
|
1476
|
+
<dd>Arbitrary data of the value</dd>
|
1477
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1478
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1479
|
+
</dl></dd>
|
1480
|
+
</dl>
|
1481
|
+
|
1482
|
+
<dl class="api">
|
1483
|
+
<dt><code>putnr</code>: for the function `tcrdbputnr'</dt>
|
1484
|
+
<dd><dl>
|
1485
|
+
<dt>Request: <code>[magic:2][ksiz:4][vsiz:4][kbuf:*][vbuf:*]</code></dt>
|
1486
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x18</dd>
|
1487
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1488
|
+
<dd>A 32-bit integer standing for the length of the value</dd>
|
1489
|
+
<dd>Arbitrary data of the key</dd>
|
1490
|
+
<dd>Arbitrary data of the value</dd>
|
1491
|
+
<dt>Response: (none)</dt>
|
1492
|
+
</dl></dd>
|
1493
|
+
</dl>
|
1494
|
+
|
1495
|
+
<dl class="api">
|
1496
|
+
<dt><code>out</code>: for the function `tcrdbout'</dt>
|
1497
|
+
<dd><dl>
|
1498
|
+
<dt>Request: <code>[magic:2][ksiz:4][kbuf:*]</code></dt>
|
1499
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x20</dd>
|
1500
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1501
|
+
<dd>Arbitrary data of the key</dd>
|
1502
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1503
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1504
|
+
</dl></dd>
|
1505
|
+
</dl>
|
1506
|
+
|
1507
|
+
<dl class="api">
|
1508
|
+
<dt><code>get</code>: for the function `tcrdbget'</dt>
|
1509
|
+
<dd><dl>
|
1510
|
+
<dt>Request: <code>[magic:2][ksiz:4][kbuf:*]</code></dt>
|
1511
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x30</dd>
|
1512
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1513
|
+
<dd>Arbitrary data of the key</dd>
|
1514
|
+
<dt>Response: <code>[code:1]([vsiz:4][vbuf:*])</code></dt>
|
1515
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1516
|
+
<dd>on success: A 32-bit integer standing for the length of the value</dd>
|
1517
|
+
<dd>on success: Arbitrary data of the value</dd>
|
1518
|
+
</dl></dd>
|
1519
|
+
</dl>
|
1520
|
+
|
1521
|
+
<dl class="api">
|
1522
|
+
<dt><code>mget</code>: for the function `tcrdbget3'</dt>
|
1523
|
+
<dd><dl>
|
1524
|
+
<dt>Request: <code>[magic:2][rnum:4][{[ksiz:4][kbuf:*]}:*]</code></dt>
|
1525
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x31</dd>
|
1526
|
+
<dd>A 32-bit integer standing for the number of keys</dd>
|
1527
|
+
<dd>iteration: A 32-bit integer standing for the length of the key</dd>
|
1528
|
+
<dd>iteration: Arbitrary data of the key</dd>
|
1529
|
+
<dt>Response: <code>[code:1][rnum:4][{[ksiz:4][vsiz:4][kbuf:*][vbuf:*]}:*]</code></dt>
|
1530
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1531
|
+
<dd>A 32-bit integer standing for the number of records</dd>
|
1532
|
+
<dd>iteration: A 32-bit integer standing for the length of the key</dd>
|
1533
|
+
<dd>iteration: A 32-bit integer standing for the length of the value</dd>
|
1534
|
+
<dd>iteration: Arbitrary data of the key</dd>
|
1535
|
+
<dd>iteration: Arbitrary data of the value</dd>
|
1536
|
+
</dl></dd>
|
1537
|
+
</dl>
|
1538
|
+
|
1539
|
+
<dl class="api">
|
1540
|
+
<dt><code>vsiz</code>: for the function `tcrdbvsiz'</dt>
|
1541
|
+
<dd><dl>
|
1542
|
+
<dt>Request: <code>[magic:2][ksiz:4][kbuf:*]</code></dt>
|
1543
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x38</dd>
|
1544
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1545
|
+
<dd>Arbitrary data of the key</dd>
|
1546
|
+
<dt>Response: <code>[code:1]([vsiz:4])</code></dt>
|
1547
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1548
|
+
<dd>on success: A 32-bit integer standing for the length of the value</dd>
|
1549
|
+
</dl></dd>
|
1550
|
+
</dl>
|
1551
|
+
|
1552
|
+
<dl class="api">
|
1553
|
+
<dt><code>iterinit</code>: for the function `tcrdbiterinit'</dt>
|
1554
|
+
<dd><dl>
|
1555
|
+
<dt>Request: <code>[magic:2]</code></dt>
|
1556
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x50</dd>
|
1557
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1558
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1559
|
+
</dl></dd>
|
1560
|
+
</dl>
|
1561
|
+
|
1562
|
+
<dl class="api">
|
1563
|
+
<dt><code>iternext</code>: for the function `tcrdbiternext'</dt>
|
1564
|
+
<dd><dl>
|
1565
|
+
<dt>Request: <code>[magic:2]</code></dt>
|
1566
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x51</dd>
|
1567
|
+
<dt>Response: <code>[code:1]([ksiz:4][kbuf:*])</code></dt>
|
1568
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1569
|
+
<dd>on success: A 32-bit integer standing for the length of the key</dd>
|
1570
|
+
<dd>on success: Arbitrary data of the key</dd>
|
1571
|
+
</dl></dd>
|
1572
|
+
</dl>
|
1573
|
+
|
1574
|
+
<dl class="api">
|
1575
|
+
<dt><code>fwmkeys</code>: for the function `tcrdbfwmkeys'</dt>
|
1576
|
+
<dd><dl>
|
1577
|
+
<dt>Request: <code>[magic:2][psiz:4][max:4][pbuf:*]</code></dt>
|
1578
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x58</dd>
|
1579
|
+
<dd>A 32-bit integer standing for the length of the prefix</dd>
|
1580
|
+
<dd>A 32-bit integer standing for the maximum number of keys to be fetched</dd>
|
1581
|
+
<dd>Arbitrary data of the prefix</dd>
|
1582
|
+
<dt>Response: <code>[code:1][knum:4][{[ksiz:4][kbuf:*]}:*]</code></dt>
|
1583
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1584
|
+
<dd>A 32-bit integer standing for the number of keys</dd>
|
1585
|
+
<dd>iteration: A 32-bit integer standing for the length of the key</dd>
|
1586
|
+
<dd>iteration: Arbitrary data of the key</dd>
|
1587
|
+
</dl></dd>
|
1588
|
+
</dl>
|
1589
|
+
|
1590
|
+
<dl class="api">
|
1591
|
+
<dt><code>addint</code>: for the function `tcrdbaddint'</dt>
|
1592
|
+
<dd><dl>
|
1593
|
+
<dt>Request: <code>[magic:2][ksiz:4][num:4][kbuf:*]</code></dt>
|
1594
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x60</dd>
|
1595
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1596
|
+
<dd>A 32-bit integer standing for the additional number</dd>
|
1597
|
+
<dd>Arbitrary data of the key</dd>
|
1598
|
+
<dt>Response: <code>[code:1]([sum:4])</code></dt>
|
1599
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1600
|
+
<dd>on success: A 32-bit integer standing for the summation value</dd>
|
1601
|
+
</dl></dd>
|
1602
|
+
</dl>
|
1603
|
+
|
1604
|
+
<dl class="api">
|
1605
|
+
<dt><code>adddouble</code>: for the function `tcrdbadddouble'</dt>
|
1606
|
+
<dd><dl>
|
1607
|
+
<dt>Request: <code>[magic:2][ksiz:4][integ:8][fract:8][kbuf:*]</code></dt>
|
1608
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x61</dd>
|
1609
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1610
|
+
<dd>A 64-bit integer standing for the integral of the additional number</dd>
|
1611
|
+
<dd>A 64-bit integer standing for the trillionfold fractional of the additional number</dd>
|
1612
|
+
<dd>Arbitrary data of the key</dd>
|
1613
|
+
<dt>Response: <code>[code:1]([integ:8][fract:8])</code></dt>
|
1614
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1615
|
+
<dd>on success: A 64-bit integer standing for the integral of the summation value</dd>
|
1616
|
+
<dd>on success: A 64-bit integer standing for the trillionfold fractional of the summation value</dd>
|
1617
|
+
</dl></dd>
|
1618
|
+
</dl>
|
1619
|
+
|
1620
|
+
<dl class="api">
|
1621
|
+
<dt><code>ext</code>: for the function `tcrdbext'</dt>
|
1622
|
+
<dd><dl>
|
1623
|
+
<dt>Request: <code>[magic:2][nsiz:4][opts:4][ksiz:4][vsiz:4][nbuf:*][kbuf:*][vbuf:*]</code></dt>
|
1624
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x68</dd>
|
1625
|
+
<dd>A 32-bit integer standing for the length of the function name</dd>
|
1626
|
+
<dd>A 32-bit integer standing for the options</dd>
|
1627
|
+
<dd>A 32-bit integer standing for the length of the key</dd>
|
1628
|
+
<dd>A 32-bit integer standing for the length of the value</dd>
|
1629
|
+
<dd>Arbitrary data of the function name</dd>
|
1630
|
+
<dd>Arbitrary data of the key</dd>
|
1631
|
+
<dd>Arbitrary data of the value</dd>
|
1632
|
+
<dt>Response: <code>[code:1]([rsiz:4][rbuf:*])</code></dt>
|
1633
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1634
|
+
<dd>on success: A 32-bit integer standing for the length of the result</dd>
|
1635
|
+
<dd>on success: Arbitrary data of the result</dd>
|
1636
|
+
</dl></dd>
|
1637
|
+
</dl>
|
1638
|
+
|
1639
|
+
<dl class="api">
|
1640
|
+
<dt><code>sync</code>: for the function `tcrdbsync'</dt>
|
1641
|
+
<dd><dl>
|
1642
|
+
<dt>Request: <code>[magic:2]</code></dt>
|
1643
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x70</dd>
|
1644
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1645
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1646
|
+
</dl></dd>
|
1647
|
+
</dl>
|
1648
|
+
|
1649
|
+
<dl class="api">
|
1650
|
+
<dt><code>optimize</code>: for the function `tcrdboptimize'</dt>
|
1651
|
+
<dd><dl>
|
1652
|
+
<dt>Request: <code>[magic:2][psiz:4][pbuf:*]</code></dt>
|
1653
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x71</dd>
|
1654
|
+
<dd>A 32-bit integer standing for the length of the parameter string</dd>
|
1655
|
+
<dd>Arbitrary data of the parameter string</dd>
|
1656
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1657
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1658
|
+
</dl></dd>
|
1659
|
+
</dl>
|
1660
|
+
|
1661
|
+
<dl class="api">
|
1662
|
+
<dt><code>vanish</code>: for the function `tcrdbvanish'</dt>
|
1663
|
+
<dd><dl>
|
1664
|
+
<dt>Request: <code>[magic:2]</code></dt>
|
1665
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x72</dd>
|
1666
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1667
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1668
|
+
</dl></dd>
|
1669
|
+
</dl>
|
1670
|
+
|
1671
|
+
<dl class="api">
|
1672
|
+
<dt><code>copy</code>: for the function `tcrdbcopy'</dt>
|
1673
|
+
<dd><dl>
|
1674
|
+
<dt>Request: <code>[magic:2][psiz:4][pbuf:*]</code></dt>
|
1675
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x73</dd>
|
1676
|
+
<dd>A 32-bit integer standing for the length of the path</dd>
|
1677
|
+
<dd>Arbitrary data of the path</dd>
|
1678
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1679
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1680
|
+
</dl></dd>
|
1681
|
+
</dl>
|
1682
|
+
|
1683
|
+
<dl class="api">
|
1684
|
+
<dt><code>restore</code>: for the function `tcrdbrestore'</dt>
|
1685
|
+
<dd><dl>
|
1686
|
+
<dt>Request: <code>[magic:2][psiz:4][ts:8][opts:4][pbuf:*]</code></dt>
|
1687
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x74</dd>
|
1688
|
+
<dd>A 32-bit integer standing for the length of the path</dd>
|
1689
|
+
<dd>A 64-bit integer standing for the beginning time stamp in microseconds</dd>
|
1690
|
+
<dd>A 32-bit integer standing for the options</dd>
|
1691
|
+
<dd>Arbitrary data of the path</dd>
|
1692
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1693
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1694
|
+
</dl></dd>
|
1695
|
+
</dl>
|
1696
|
+
|
1697
|
+
<dl class="api">
|
1698
|
+
<dt><code>setmst</code>: for the function `tcrdbsetmst'</dt>
|
1699
|
+
<dd><dl>
|
1700
|
+
<dt>Request: <code>[magic:2][hsiz:4][port:4][ts:8][opts:4][host:*]</code></dt>
|
1701
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x78</dd>
|
1702
|
+
<dd>A 32-bit integer standing for the length of the host name</dd>
|
1703
|
+
<dd>A 32-bit integer standing for the port number</dd>
|
1704
|
+
<dd>A 64-bit integer standing for the beginning time stamp in microseconds</dd>
|
1705
|
+
<dd>A 32-bit integer standing for the options</dd>
|
1706
|
+
<dd>Arbitrary data of the host name</dd>
|
1707
|
+
<dt>Response: <code>[code:1]</code></dt>
|
1708
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1709
|
+
</dl></dd>
|
1710
|
+
</dl>
|
1711
|
+
|
1712
|
+
<dl class="api">
|
1713
|
+
<dt><code>rnum</code>: for the function `tcrdbrnum'</dt>
|
1714
|
+
<dd><dl>
|
1715
|
+
<dt>Request: <code>[magic:2]</code></dt>
|
1716
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x80</dd>
|
1717
|
+
<dt>Response: <code>[code:1][rnum:8]</code></dt>
|
1718
|
+
<dd>An 8-bit integer whose value is always 0</dd>
|
1719
|
+
<dd>A 64-bit integer standing for the number of records</dd>
|
1720
|
+
</dl></dd>
|
1721
|
+
</dl>
|
1722
|
+
|
1723
|
+
<dl class="api">
|
1724
|
+
<dt><code>size</code>: for the function `tcrdbsize'</dt>
|
1725
|
+
<dd><dl>
|
1726
|
+
<dt>Request: <code>[magic:2]</code></dt>
|
1727
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x81</dd>
|
1728
|
+
<dt>Response: <code>[code:1][rnum:8]</code></dt>
|
1729
|
+
<dd>An 8-bit integer whose value is always 0</dd>
|
1730
|
+
<dd>A 64-bit integer standing for the size of the database</dd>
|
1731
|
+
</dl></dd>
|
1732
|
+
</dl>
|
1733
|
+
|
1734
|
+
<dl class="api">
|
1735
|
+
<dt><code>stat</code>: for the function `tcrdbstat'</dt>
|
1736
|
+
<dd><dl>
|
1737
|
+
<dt>Request: <code>[magic:2]</code></dt>
|
1738
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x88</dd>
|
1739
|
+
<dt>Response: <code>[code:1][ssiz:4][sbuf:*]</code></dt>
|
1740
|
+
<dd>An 8-bit integer whose value is always 0</dd>
|
1741
|
+
<dd>A 32-bit integer standing for the length of the status message</dd>
|
1742
|
+
<dd>Arbitrary data of the result</dd>
|
1743
|
+
</dl></dd>
|
1744
|
+
</dl>
|
1745
|
+
|
1746
|
+
<dl class="api">
|
1747
|
+
<dt><code>misc</code>: for the function `tcrdbmisc'</dt>
|
1748
|
+
<dd><dl>
|
1749
|
+
<dt>Request: <code>[magic:2][nsiz:4][opts:4][rnum:4][nbuf:*][{[asiz:4][abuf:*]}:*]</code></dt>
|
1750
|
+
<dd>Two bytes of the command ID: 0xC8 and 0x90</dd>
|
1751
|
+
<dd>A 32-bit integer standing for the length of the function name</dd>
|
1752
|
+
<dd>A 32-bit integer standing for the options</dd>
|
1753
|
+
<dd>A 32-bit integer standing for the number of arguments</dd>
|
1754
|
+
<dd>Arbitrary data of the function name</dd>
|
1755
|
+
<dd>iteration: A 32-bit integer standing for the length of the argument</dd>
|
1756
|
+
<dd>iteration: Arbitrary data of the argument</dd>
|
1757
|
+
<dt>Response: <code>[code:1][rnum:4][{[esiz:4][ebuf:*]}:*]</code></dt>
|
1758
|
+
<dd>An 8-bit integer whose value is 0 on success or another on failure</dd>
|
1759
|
+
<dd>A 32-bit integer standing for the number of result elements</dd>
|
1760
|
+
<dd>iteration: A 32-bit integer standing for the length of the element</dd>
|
1761
|
+
<dd>iteration: Arbitrary data of the element</dd>
|
1762
|
+
</dl></dd>
|
1763
|
+
</dl>
|
1764
|
+
|
1765
|
+
<p>To finish the session, the client can shutdown and close the socket at any time. If not closed, the connection can be reused for the next session. If protocol violation or some fatal error occurs, the server immediately breaks the session and closes the connection.</p>
|
1766
|
+
|
1767
|
+
<h3 id="protocol_memcached">Memcached Compatible Protocol</h3>
|
1768
|
+
|
1769
|
+
<p>As for the memcached (ASCII) compatible protocol, the server implements the following commands; "set", "add", "replace", "get", "delete", "incr", "decr", "stats", "flush_all", "version", and "quit". "noreply" options of update commands are also supported. However, "flags", "exptime", and "cas unique" parameters are ignored.</p>
|
1770
|
+
|
1771
|
+
<h3 id="protocol_http">HTTP Compatible Protocol</h3>
|
1772
|
+
|
1773
|
+
<p>As for the HTTP (1.1) compatible protocol, the server implements the following commands; "GET" (relevant to `tcrdbget'), "HEAD" (relevant to `tcrdbvsiz'), "PUT" (relevant to `tcrdbput'), "POST" (relevant to `tcrdbext'), "DELETE" (relevant to `tcrdbout'), and "OPTIONS" (relevant to `tcrdbstat'). The URI of each request is treated as the key encoded by the URL encoding. And the entity body is treated as the value. However, headers except for "Connection" and "Content-Length" are ignored. "PUT" can have the header "X-TT-PDMODE" whose value is either of 1 (relevant to `tcrdbputkeep'), 2 (relevant to `tcrdbputcat'), or else (relevant to `tcrdbput').</p>
|
1774
|
+
|
1775
|
+
<p>"POST" should have one of the header "X-TT-XNAME" or the header "X-TT-MNAME". "X-TT-XNAME" is relevant to `tcrdbext' and specifies the function name. The header "X-TT-XOPTS" stands for bitwise-or options of 1 (record locking) and 2 (global locking). The URI of each request is treated as the key encoded by the URL encoding. And the entity body is treated as the value. The result is expressed as the entity body of the response. "X-TT-MNAME" is relevant to `tcrdbmisc' and specifies the function name. The header "X-TT-MOPTS" stands for bitwise-or options of 1 (omission of the update log). The request parameters are expressed as the entity body in the "application/x-www-form-urlencoded" format. The names are ignored and the values are treated as a list of the parameters. The result is expressed as the entity body of the response in the "application/x-www-form-urlencoded" format.</p>
|
1776
|
+
|
1777
|
+
<hr />
|
1778
|
+
|
1779
|
+
<h2 id="tutorial">Tutorial</h2>
|
1780
|
+
|
1781
|
+
<h3 id="tutorial_basic">Basic Use</h3>
|
1782
|
+
|
1783
|
+
<p>After installation of Tokyo Tyrant, you can start the server immediately by executing the command `<code>ttserver</code>' in the terminal. By default, the server listens to the port 1978 and serves as the accessor of an on-memory hash database, which is useful to store cache data.</p>
|
1784
|
+
|
1785
|
+
<pre>[terminal-1]$ ttserver
|
1786
|
+
</pre>
|
1787
|
+
|
1788
|
+
<p>To test storing operations, execute the following commands in another terminal. `<code>tcrmgr put</code>' calls the function `<code>tcrdbput</code>'.</p>
|
1789
|
+
|
1790
|
+
<pre>[terminal-2]$ tcrmgr put localhost one first
|
1791
|
+
[terminal-2]$ tcrmgr put localhost two second
|
1792
|
+
[terminal-2]$ tcrmgr put localhost three third
|
1793
|
+
</pre>
|
1794
|
+
|
1795
|
+
<p>To test retrieving operations, execute the following commands in another terminal. `<code>tcrmgr get</code>' calls the function `<code>tcrdbget</code>'.</p>
|
1796
|
+
|
1797
|
+
<pre>[terminal-2]$ tcrmgr get localhost one
|
1798
|
+
[terminal-2]$ tcrmgr get localhost two
|
1799
|
+
[terminal-2]$ tcrmgr get localhost three
|
1800
|
+
</pre>
|
1801
|
+
|
1802
|
+
<p>To retrieve multiple records at once, execute the following command. `<code>tcrmgr mget</code>' calls the function `<code>tcrdbget3</code>'.</p>
|
1803
|
+
|
1804
|
+
<pre>[terminal-2]$ tcrmgr mget localhost one two three
|
1805
|
+
</pre>
|
1806
|
+
|
1807
|
+
<p>To terminate the server, input Ctrl-C in the terminal of the server.</p>
|
1808
|
+
|
1809
|
+
<p>Next, let's run the server that handles a hash database, by specifying the file name whose suffix is `<code>.tch</code>'.</p>
|
1810
|
+
|
1811
|
+
<pre>[terminal-1]$ ttserver casket.tch
|
1812
|
+
</pre>
|
1813
|
+
|
1814
|
+
<p>Store some records.</p>
|
1815
|
+
|
1816
|
+
<pre>[terminal-2]$ tcrmgr put localhost one first
|
1817
|
+
[terminal-2]$ tcrmgr put localhost two second
|
1818
|
+
[terminal-2]$ tcrmgr put localhost three third
|
1819
|
+
</pre>
|
1820
|
+
|
1821
|
+
<p>Terminate the server by Ctrl-C, and then restart the server.</p>
|
1822
|
+
|
1823
|
+
<pre>[terminal-1]$ ttserver casket.tch
|
1824
|
+
</pre>
|
1825
|
+
|
1826
|
+
<p>Check consistency of stored records.</p>
|
1827
|
+
|
1828
|
+
<pre>[terminal-2]$ tcrmgr mget localhost one two three
|
1829
|
+
</pre>
|
1830
|
+
|
1831
|
+
<p>Terminate the server by Ctrl-C and remove the database, for the successive tutorial.</p>
|
1832
|
+
|
1833
|
+
<pre>[terminal-1]$ rm casket.tch
|
1834
|
+
</pre>
|
1835
|
+
|
1836
|
+
<h3 id="tutorial_daemon">Daemon</h3>
|
1837
|
+
|
1838
|
+
<p>To run the server as a daemon process, specify the option `<code>-dmn</code>'. Moreover, the option `<code>-pid</code>' should be specified to record the process ID into a file. Note that the current directory of the daemon process is changed to the root directory. So, the file path parameter should be expressed as the absolute path.</p>
|
1839
|
+
|
1840
|
+
<pre>[terminal-1]$ ttserver -dmn -pid /tmp/ttserver.pid /tmp/casket.tch
|
1841
|
+
</pre>
|
1842
|
+
|
1843
|
+
<p>To terminate the daemonized server, check the process ID from the file specified by `<code>-pid</code>' and send the SIGTERM signal to the process.</p>
|
1844
|
+
|
1845
|
+
<pre>[terminal-1]$ kill -TERM `cat /tmp/ttserver.pid`
|
1846
|
+
</pre>
|
1847
|
+
|
1848
|
+
<p>To run the server by the RC script of the operating system, use `<code>ttservctl</code>'. As for most Linux distribution, append the following line to `<code>/etc/rc.local</code>'.</p>
|
1849
|
+
|
1850
|
+
<pre>/usr/local/sbin/ttservctl start
|
1851
|
+
</pre>
|
1852
|
+
|
1853
|
+
<p>By default, the database file and the related files are placed under `<code>/var/ttserver</code>'. Because `<code>ttservctl</code>' is a tiny shell script, copy and edit it for your purpose. Also, it is suitable to install the modified script into `<code>/etc/init.d</code>' and set symbolic links from `<code>/etc/rc3.d/S98ttserver</code>' and `<code>/etc/rc5.d/S98ttserver</code>'.</p>
|
1854
|
+
|
1855
|
+
<h3 id="tutorial_backup">Backup and Recovery</h3>
|
1856
|
+
|
1857
|
+
<p>Let's run the server again to continue this tutorial.</p>
|
1858
|
+
|
1859
|
+
<pre>[terminal-1]$ ttserver casket.tch
|
1860
|
+
</pre>
|
1861
|
+
|
1862
|
+
<p>Store some records.</p>
|
1863
|
+
|
1864
|
+
<pre>[terminal-2]$ tcrmgr put localhost one first
|
1865
|
+
[terminal-2]$ tcrmgr put localhost two second
|
1866
|
+
[terminal-2]$ tcrmgr put localhost three third
|
1867
|
+
</pre>
|
1868
|
+
|
1869
|
+
<p>To back up the database file, indicate the destination path to the server by the command `<code>tcrmgr copy</code>'. Note that the backup file is created on the local file system of the server (not on the client side).</p>
|
1870
|
+
|
1871
|
+
<pre>[terminal-2]$ tcrmgr copy localhost backup.tch
|
1872
|
+
</pre>
|
1873
|
+
|
1874
|
+
<p>Terminate the server by Ctrl-C and remove the database.</p>
|
1875
|
+
|
1876
|
+
<pre>[terminal-1]$ rm casket.tch
|
1877
|
+
</pre>
|
1878
|
+
|
1879
|
+
<p>Recover the database from the backup file and restart the server.</p>
|
1880
|
+
|
1881
|
+
<pre>[terminal-1]$ cp backup.tch casket.tch
|
1882
|
+
[terminal-1]$ ttserver casket.tch
|
1883
|
+
</pre>
|
1884
|
+
|
1885
|
+
<p>Check consistency of stored records.</p>
|
1886
|
+
|
1887
|
+
<pre>[terminal-2]$ tcrmgr mget localhost one two three
|
1888
|
+
</pre>
|
1889
|
+
|
1890
|
+
<p>Terminate the server by Ctrl-C and remove the databases, for the successive tutorial.</p>
|
1891
|
+
|
1892
|
+
<pre>[terminal-1]$ rm casket.tch backup.tch
|
1893
|
+
</pre>
|
1894
|
+
|
1895
|
+
<h3 id="tutorial_ulog">Update Log</h3>
|
1896
|
+
|
1897
|
+
<p>Let's run the server with update logging enabled. The option `<code>-ulog</code>' specifies the directory to contain the update log files.</p>
|
1898
|
+
|
1899
|
+
<pre>[terminal-1]$ mkdir ulog
|
1900
|
+
[terminal-1]$ ttserver -ulog ulog casket.tch
|
1901
|
+
</pre>
|
1902
|
+
|
1903
|
+
<p>Store some records.</p>
|
1904
|
+
|
1905
|
+
<pre>[terminal-2]$ tcrmgr put localhost one first
|
1906
|
+
[terminal-2]$ tcrmgr put localhost two second
|
1907
|
+
[terminal-2]$ tcrmgr put localhost three third
|
1908
|
+
</pre>
|
1909
|
+
|
1910
|
+
<p>Terminate the server by Ctrl-C and remove the database.</p>
|
1911
|
+
|
1912
|
+
<pre>[terminal-1]$ rm casket.tch
|
1913
|
+
</pre>
|
1914
|
+
|
1915
|
+
<p>Escape the update log directoty and restart the server.</p>
|
1916
|
+
|
1917
|
+
<pre>[terminal-1]$ mv ulog ulog-back
|
1918
|
+
[terminal-1]$ mkdir ulog
|
1919
|
+
[terminal-1]$ ttserver -ulog ulog casket.tch
|
1920
|
+
</pre>
|
1921
|
+
|
1922
|
+
<p>Restore the database from the escaped update log, by the command `<code>tcrmgr restore</code>' on the client side.</p>
|
1923
|
+
|
1924
|
+
<pre>[terminal-2]$ tcrmgr restore localhost ulog-back
|
1925
|
+
</pre>
|
1926
|
+
|
1927
|
+
<p>Check consistency of stored records.</p>
|
1928
|
+
|
1929
|
+
<pre>[terminal-2]$ tcrmgr mget localhost one two three
|
1930
|
+
</pre>
|
1931
|
+
|
1932
|
+
<p>Terminate the server by Ctrl-C and remove the database, for the successive tutorial.</p>
|
1933
|
+
|
1934
|
+
<pre>[terminal-1]$ rm -rf casket.tch ulog ulog-back
|
1935
|
+
</pre>
|
1936
|
+
|
1937
|
+
<h3 id="tutorial_replication">Replication</h3>
|
1938
|
+
|
1939
|
+
<p>Replication is a mechanism to synchronize two or more database servers for high availability and high integrity. The replication source server is called "master" and each destination server is called "slave". Replication requires the following preconditions.</p>
|
1940
|
+
|
1941
|
+
<ul>
|
1942
|
+
<li>The master must record the update log.</li>
|
1943
|
+
<li>The master must specify the unique server ID.</li>
|
1944
|
+
<li>Each slave must record the update log because it may become the master when fail over.</li>
|
1945
|
+
<li>Each slave must specify the unique server ID because it may become the master when fail over.</li>
|
1946
|
+
<li>Each slave must specify the address and the port number of the master server.</li>
|
1947
|
+
<li>Each slave must specify the replication time stamp file.</li>
|
1948
|
+
</ul>
|
1949
|
+
|
1950
|
+
<p>This section describes how to set up one master (at port 1978) and one slave (at port 1979) replication. First, let's run the master server.</p>
|
1951
|
+
|
1952
|
+
<pre>[terminal-1]$ mkdir ulog-1
|
1953
|
+
[terminal-1]$ ttserver -port 1978 -ulog ulog-1 -sid 1 casket-1.tch
|
1954
|
+
</pre>
|
1955
|
+
|
1956
|
+
<p>Next, let's run the slave server in another terminal.</p>
|
1957
|
+
|
1958
|
+
<pre>[terminal-2]$ mkdir ulog-2
|
1959
|
+
[terminal-2]$ ttserver -port 1979 -ulog ulog-2 -sid 2 \
|
1960
|
+
-mhost localhost -mport 1978 -rts 2.rts casket-2.tch
|
1961
|
+
</pre>
|
1962
|
+
|
1963
|
+
<p>Store some records into the master.</p>
|
1964
|
+
|
1965
|
+
<pre>[terminal-3]$ tcrmgr put -port 1978 localhost one first
|
1966
|
+
[terminal-3]$ tcrmgr put -port 1978 localhost two second
|
1967
|
+
[terminal-3]$ tcrmgr put -port 1978 localhost three third
|
1968
|
+
</pre>
|
1969
|
+
|
1970
|
+
<p>Check consistency of stored records in the master and the slave.</p>
|
1971
|
+
|
1972
|
+
<pre>[terminal-2]$ tcrmgr mget -port 1978 localhost one two three
|
1973
|
+
[terminal-2]$ tcrmgr mget -port 1979 localhost one two three
|
1974
|
+
</pre>
|
1975
|
+
|
1976
|
+
<p>Let's simulate the case that the master is crashed. Terminate the master by Ctrl-C and remove the database file.</p>
|
1977
|
+
|
1978
|
+
<pre>[terminal-1]$ rm casket-1.tch
|
1979
|
+
</pre>
|
1980
|
+
|
1981
|
+
<p>Terminate the slave by Ctrl-C and restart it as the new master.</p>
|
1982
|
+
|
1983
|
+
<pre>[terminal-2]$ ttserver -port 1979 -ulog ulog-2 -sid 2 casket-2.tch
|
1984
|
+
</pre>
|
1985
|
+
|
1986
|
+
<p>Add the new slave (at port 1980).</p>
|
1987
|
+
|
1988
|
+
<pre>[terminal-1]$ mkdir ulog-3
|
1989
|
+
[terminal-1]$ ttserver -port 1980 -ulog ulog-3 -sid 3 \
|
1990
|
+
-mhost localhost -mport 1979 -rts 3.rts casket-3.tch
|
1991
|
+
</pre>
|
1992
|
+
|
1993
|
+
<p>Check consistency of stored records in the new master and the new slave.</p>
|
1994
|
+
|
1995
|
+
<pre>[terminal-2]$ tcrmgr mget -port 1979 localhost one two three
|
1996
|
+
[terminal-2]$ tcrmgr mget -port 1980 localhost one two three
|
1997
|
+
</pre>
|
1998
|
+
|
1999
|
+
<p>Terminate the two servers by Ctrl-C and remove the database and related files.</p>
|
2000
|
+
|
2001
|
+
<pre>[terminal-1]$ rm -rf casket-1.tch ulog-1 1.rts
|
2002
|
+
[terminal-2]$ rm -rf casket-2.tch ulog-2 2.rts
|
2003
|
+
[terminal-1]$ rm -rf casket-3.tch ulog-3 3.rts
|
2004
|
+
</pre>
|
2005
|
+
|
2006
|
+
<p>Tokyo Tyrant supports "dual master" replication which realizes higher availability. To do it, run two servers which replicate each other. Note that updating both of the masters at the same time may cause inconsistency of their databases. By default, the servers do not complain even if inconsistency is detected. The option `<code>-rcc</code>' make them check the consistency and stop replication when inconsistency is detected.</p>
|
2007
|
+
|
2008
|
+
<h3 id="tutorial_repondemand">Setting Replication on Demand</h3>
|
2009
|
+
|
2010
|
+
<p>You can set replication of the running database service without any downtime. First, prepare the following script for backup operation and save it as "ttbackup.sh" with executable permission (0755).</p>
|
2011
|
+
|
2012
|
+
<pre>#! /bin/sh
|
2013
|
+
srcpath="$1"
|
2014
|
+
destpath="$1.$2"
|
2015
|
+
rm -f "$destpath"
|
2016
|
+
cp -f "$srcpath" "$destpath"
|
2017
|
+
</pre>
|
2018
|
+
|
2019
|
+
<p>Next, let's run the master with update log enabled.</p>
|
2020
|
+
|
2021
|
+
<pre>[terminal-1]$ mkdir ulog-1
|
2022
|
+
[terminal-1]$ ttserver -port 1978 -ulog ulog-1 -sid 1 casket-1.tch
|
2023
|
+
</pre>
|
2024
|
+
|
2025
|
+
<p>Store a volume of records into the master.</p>
|
2026
|
+
|
2027
|
+
<pre>[terminal-2]$ tcrtest write -port 1978 localhost 10000
|
2028
|
+
</pre>
|
2029
|
+
|
2030
|
+
<p>Check consistency of stored records.</p>
|
2031
|
+
|
2032
|
+
<pre>[terminal-2]$ tcrmgr list -port 1978 -pv localhost
|
2033
|
+
</pre>
|
2034
|
+
|
2035
|
+
<p>Backup the database.</p>
|
2036
|
+
|
2037
|
+
<pre>[terminal-2]$ tcrmgr copy -port 1978 localhost '@./ttbackup.sh'
|
2038
|
+
</pre>
|
2039
|
+
|
2040
|
+
<p>Confirm that the backup file was saved as "casket-1.tch.<var>xxxxx</var>" ("<var>xxxxx</var>" stands for the time stamp of the backup file). Then, run the slave with the backup file.</p>
|
2041
|
+
|
2042
|
+
<pre>[terminal-2]$ ls
|
2043
|
+
[terminal-2]$ cp casket-1.tch.<var>xxxxx</var> casket-2.tch
|
2044
|
+
[terminal-2]$ echo <var>xxxxx</var> > 2.rts
|
2045
|
+
[terminal-2]$ mkdir ulog-2
|
2046
|
+
[terminal-2]$ ttserver -port 1979 -ulog ulog-2 -sid 2 -rts 2.rts casket-2.tch
|
2047
|
+
</pre>
|
2048
|
+
|
2049
|
+
<p>Note that the above operation did not specify the master server to the slave. For tutorial, let's simulate that some records are stored into the master by users while you are setting replication.</p>
|
2050
|
+
|
2051
|
+
<pre>[terminal-3]$ tcrmgr put -port 1978 localhost one first
|
2052
|
+
[terminal-3]$ tcrmgr put -port 1978 localhost two second
|
2053
|
+
[terminal-3]$ tcrmgr put -port 1978 localhost three third
|
2054
|
+
</pre>
|
2055
|
+
|
2056
|
+
<p>Check the difference between the master and the slave.</p>
|
2057
|
+
|
2058
|
+
<pre>[terminal-3]$ tcrmgr inform -port 1978 localhost
|
2059
|
+
[terminal-3]$ tcrmgr inform -port 1979 localhost
|
2060
|
+
</pre>
|
2061
|
+
|
2062
|
+
<p>Specify the master to the slave so that replication will start and the difference will be resolved.</p>
|
2063
|
+
|
2064
|
+
<pre>[terminal-3]$ tcrmgr setmst -port 1979 -mport 1978 localhost localhost
|
2065
|
+
</pre>
|
2066
|
+
|
2067
|
+
<p>Confirm that the slave knows the master and the difference has been resolved.</p>
|
2068
|
+
|
2069
|
+
<pre>[terminal-3]$ tcrmgr inform -port 1979 -st localhost
|
2070
|
+
</pre>
|
2071
|
+
|
2072
|
+
<p>Terminate the two servers by Ctrl-C and remove the database and related files.</p>
|
2073
|
+
|
2074
|
+
<pre>[terminal-1]$ rm -rf casket-1.tch casket-1.tch.* ulog-1 1.rts ttbackup.sh
|
2075
|
+
[terminal-2]$ rm -rf casket-2.tch ulog-2 2.rts
|
2076
|
+
</pre>
|
2077
|
+
|
2078
|
+
<h3 id="tutorial_tuning">Tuning</h3>
|
2079
|
+
|
2080
|
+
<p>If you use a hash database, set the tuning parameter "#bnum=<var>xxx</var>" to improve performance. It specifies the bucket number and should be more than the number of record to be stored.</p>
|
2081
|
+
|
2082
|
+
<p>If you use a B+ tree database, set the tuning parameters "#lcnum=<var>xxx</var>#bnum=<var>yyy</var>" to improve performance. The former specifies the maximum number of leaf nodes to be cached. It should be larger as long as the capacity of RAM on the system allows. The latter specifies the bucket number and should be more than 1/128 of the number of records to be stored.</p>
|
2083
|
+
|
2084
|
+
<p>If huge number of clients access the server, make sure the limit number of file descriptors per process is cleared. By default on most systems, it is set as 1024. If so, use `<code>ulimit</code>' to clear it.</p>
|
2085
|
+
|
2086
|
+
<p>In order to deal with rushing queries at the peak time of your service, replication combining the on-memory hash/tree database and the file hash/tree database is useful. The master server handles the on-memory database and it can come through rushing queries at the peak time. Though the on-memory database can not assure the data persistence, the slave of replication compensates the shortage by storing records in the file database.</p>
|
2087
|
+
|
2088
|
+
<h3 id="tutorial_luaext">Lua Extension</h3>
|
2089
|
+
|
2090
|
+
<p>If you want more complex database operations than existing ones, use the Lua extension. For example, prepare the following script and save it as "test.lua". There is a function "fibonacci" which returns the Fibonacci number of a number of the key.</p>
|
2091
|
+
|
2092
|
+
<pre>function fibonacci(key, value)
|
2093
|
+
local num = tonumber(key)
|
2094
|
+
local large = math.pow((1 + math.sqrt(5)) / 2, num)
|
2095
|
+
local small = math.pow((1 - math.sqrt(5)) / 2, num)
|
2096
|
+
return (large - small) / math.sqrt(5)
|
2097
|
+
end
|
2098
|
+
</pre>
|
2099
|
+
|
2100
|
+
<p>Let's start the server by making it read the script file.</p>
|
2101
|
+
|
2102
|
+
<pre>[terminal-1]$ ttserver -ext test.lua
|
2103
|
+
</pre>
|
2104
|
+
|
2105
|
+
<p>Call the function from the client command.</p>
|
2106
|
+
|
2107
|
+
<pre>[terminal-2]$ tcrmgr ext localhost fibonacci 1
|
2108
|
+
[terminal-2]$ tcrmgr ext localhost fibonacci 2
|
2109
|
+
[terminal-2]$ tcrmgr ext localhost fibonacci 3
|
2110
|
+
[terminal-2]$ tcrmgr ext localhost fibonacci 4
|
2111
|
+
[terminal-2]$ tcrmgr ext localhost fibonacci 5
|
2112
|
+
[terminal-2]$ tcrmgr ext localhost fibonacci 6
|
2113
|
+
</pre>
|
2114
|
+
|
2115
|
+
<p>Fibonacci numbers can be generated by another algorithm, which is naive and stateful. Add the following script to "test.lua". There is a function "fibnext" which returns the next Fibonacci number from the database. The state information are stored in the database.</p>
|
2116
|
+
|
2117
|
+
<pre>function fibnext(key, value)
|
2118
|
+
local cur = tonumber(_get("fibcur"))
|
2119
|
+
if not cur then
|
2120
|
+
_put("fibold", 0)
|
2121
|
+
_put("fibcur", 1)
|
2122
|
+
return 1
|
2123
|
+
end
|
2124
|
+
local old = tonumber(_get("fibold"))
|
2125
|
+
_put("fibold", cur)
|
2126
|
+
cur = old + cur
|
2127
|
+
_put("fibcur", cur)
|
2128
|
+
return cur
|
2129
|
+
end
|
2130
|
+
</pre>
|
2131
|
+
|
2132
|
+
<p>Then, restart the server and test the new algorithm.</p>
|
2133
|
+
|
2134
|
+
<pre>[terminal-2]$ tcrmgr ext localhost fibnext
|
2135
|
+
[terminal-2]$ tcrmgr ext localhost fibnext
|
2136
|
+
[terminal-2]$ tcrmgr ext localhost fibnext
|
2137
|
+
[terminal-2]$ tcrmgr ext localhost fibnext
|
2138
|
+
[terminal-2]$ tcrmgr ext localhost fibnext
|
2139
|
+
[terminal-2]$ tcrmgr ext localhost fibnext
|
2140
|
+
</pre>
|
2141
|
+
|
2142
|
+
<p>As you see, the called function receives two string parameters of the key and the value. The return value is sent back to the client. You can use such built-in functions for database operations as "_put", "_out", "_get", and so on. There is a sample file `<code>ext/senatus.lua</code>'.</p>
|
2143
|
+
|
2144
|
+
<h3 id="tutorial_memcached">Using memcached Client</h3>
|
2145
|
+
|
2146
|
+
<p>This section describes how to use a memcached client library of Perl (Cache::Memcached) with Tokyo Tyrant. Run the server of Tokyo Tyrant as usual. And, the following script is a typical example.</p>
|
2147
|
+
|
2148
|
+
<pre>use Cache::Memcached;
|
2149
|
+
|
2150
|
+
my $memd = Cache::Memcached->new();
|
2151
|
+
$memd->set_servers(['localhost:1978']);
|
2152
|
+
|
2153
|
+
$memd->set('one', 'first');
|
2154
|
+
$memd->set('two', 'second');
|
2155
|
+
$memd->set('three', 'third');
|
2156
|
+
|
2157
|
+
my $val = $memd->get('one');
|
2158
|
+
printf("one: %s\n", $val);
|
2159
|
+
|
2160
|
+
$val = $memd->get_multi('one', 'two', 'three');
|
2161
|
+
printf("one: %s\n", $val->{one});
|
2162
|
+
printf("two: %s\n", $val->{two});
|
2163
|
+
printf("three: %s\n", $val->{three});
|
2164
|
+
|
2165
|
+
$memd->delete('one');
|
2166
|
+
</pre>
|
2167
|
+
|
2168
|
+
<h3 id="tutorial_http">Using HTTP Client</h3>
|
2169
|
+
|
2170
|
+
<p>This section describes how to use an HTTP client library of Perl (LWP::UserAgent) with Tokyo Tyrant. Run the server of Tokyo Tyrant as usual. And, the following script is a typical example.</p>
|
2171
|
+
|
2172
|
+
<pre>use LWP::UserAgent;
|
2173
|
+
|
2174
|
+
my $ua = LWP::UserAgent->new(keep_alive => 1);
|
2175
|
+
my $baseurl = 'http://localhost:1978/';
|
2176
|
+
|
2177
|
+
my $req;
|
2178
|
+
$req = HTTP::Request->new(PUT => $baseurl . 'one', [], 'first');
|
2179
|
+
$ua->request($req);
|
2180
|
+
$req = HTTP::Request->new(PUT => $baseurl . 'two', ["X-TT-PDMODE" => 1], 'second');
|
2181
|
+
$ua->request($req);
|
2182
|
+
$req = HTTP::Request->new(PUT => $baseurl . 'three', ["X-TT-PDMODE" => 2], 'third');
|
2183
|
+
$ua->request($req);
|
2184
|
+
|
2185
|
+
$req = HTTP::Request->new(GET => $baseurl . 'one');
|
2186
|
+
my $res = $ua->request($req);
|
2187
|
+
if($res->is_success()){
|
2188
|
+
printf("%s\n", $res->content());
|
2189
|
+
}
|
2190
|
+
|
2191
|
+
$req = HTTP::Request->new(DELETE => $baseurl . 'one');
|
2192
|
+
$res = $ua->request($req);
|
2193
|
+
|
2194
|
+
$req = HTTP::Request->new(POST => $baseurl . 'foo',
|
2195
|
+
["X-TT-XNAME" => "echo", "X-TT-XOPTS" => 1], 'bar');
|
2196
|
+
$res = $ua->request($req);
|
2197
|
+
if($res->is_success()){
|
2198
|
+
printf("%s\n", $res->content());
|
2199
|
+
}
|
2200
|
+
</pre>
|
2201
|
+
|
2202
|
+
<h3 id="tutorial_expcache">Persistent but Expirable Cache</h3>
|
2203
|
+
|
2204
|
+
<p>If you want to cache data like session information for your Web application but want to avoid data loss because of the server crash, using Tokyo Tyrant can be the solution, that is to say, "persistent" but expirable cache. It requires the following preconditions.</p>
|
2205
|
+
|
2206
|
+
<ul>
|
2207
|
+
<li>The server must open a table database.</li>
|
2208
|
+
<li>Clients should store each record with an expiration date column.</li>
|
2209
|
+
<li>The database should have an index for the expiration date column.</li>
|
2210
|
+
<li>The database should enable auto defragmentation.</li>
|
2211
|
+
<li>The server must periodically call the user defined function provided through the Lua extension.</li>
|
2212
|
+
</ul>
|
2213
|
+
|
2214
|
+
<p>First, prepare the following script for expiration and save it as "ttexpire.lua". It will expire records where the value of the "x" column exceeds the current date.</p>
|
2215
|
+
|
2216
|
+
<pre>function expire()
|
2217
|
+
local args = {}
|
2218
|
+
local cdate = string.format("%d", _time())
|
2219
|
+
table.insert(args, "addcond\0x\0NUMLE\0" .. cdate)
|
2220
|
+
table.insert(args, "out")
|
2221
|
+
local res = _misc("search", args)
|
2222
|
+
if not res then
|
2223
|
+
_log("expiration was failed", 2)
|
2224
|
+
end
|
2225
|
+
end
|
2226
|
+
</pre>
|
2227
|
+
|
2228
|
+
<p>Start the server by opening a table database which has the index for the "x" column, and by scheduling it to call the expiration function per second.</p>
|
2229
|
+
|
2230
|
+
<pre>[terminal-1]$ ttserver -ext ttexpire.lua -extpc expire 1.0 "casket.tct#idx=x:dec#dfunit=8"
|
2231
|
+
</pre>
|
2232
|
+
|
2233
|
+
<p>Store test records from another terminal.</p>
|
2234
|
+
|
2235
|
+
<pre>[terminal-2]$ now=`date +%s`
|
2236
|
+
for((i=1;i<=60;i++)); do
|
2237
|
+
tcrmgr put -sep '|' localhost "$i" "x|$((now+i))"
|
2238
|
+
done
|
2239
|
+
</pre>
|
2240
|
+
|
2241
|
+
<p>You can confirm that the records are being removed by expiration.</p>
|
2242
|
+
|
2243
|
+
<pre>[terminal-2]$ tcrmgr list -pv -sep '|' localhost
|
2244
|
+
</pre>
|
2245
|
+
|
2246
|
+
<hr />
|
2247
|
+
|
2248
|
+
<h2 id="license">License</h2>
|
2249
|
+
|
2250
|
+
<p>Tokyo Tyrant is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License or any later version.</p>
|
2251
|
+
|
2252
|
+
<p>Tokyo Tyrant is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</p>
|
2253
|
+
|
2254
|
+
<p>You should have received a copy of the GNU Lesser General Public License along with Tokyo Tyrant (See the file `<code>COPYING</code>'); if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.</p>
|
2255
|
+
|
2256
|
+
<p>Tokyo Tyrant was written by Mikio Hirabayashi. You can contact the author by e-mail to `<code>hirarin@gmail.com</code>'.</p>
|
2257
|
+
|
2258
|
+
<hr />
|
2259
|
+
|
2260
|
+
</body>
|
2261
|
+
|
2262
|
+
</html>
|
2263
|
+
|
2264
|
+
<!-- END OF FILE -->
|