tdserver is also an open source project on CodeRepose.
http://svn.coderepos.org/share/lang/c/tdserver/trunk/
1. COMPILE
Compile Tokyo Cabinet, Tyrant, Dystopia and then tdserver.
You don't need to install them at this time.
wget http://tokyocabinet.sourceforge.net/tokyocabinet-1.4.17.tar.gz
wget http://tokyocabinet.sourceforge.net/tyrantpkg/tokyotyrant-1.1.23.tar.gz
wget http://tokyocabinet.sourceforge.net/dystopiapkg/tokyodystopia-0.9.11.tar.gz
tar zxvf tokyocabinet-1.4.17.tar.gz
tar zxvf tokyotyrant-1.1.23.tar.gz
tar zxvf tokyodystopia-0.9.11.tar.gz
cd tokyocabinet-1.4.17
./configure && make
cd ..
cd tokyotyrant-1.1.23
CFLAGS=-I../tokyocabinet-1.4.17 LDFLAGS=-L../tokyocabinet-1.4.17 ./configure && make
cd ..
cd tokyodystopia-0.9.11
CFLAGS=-I../tokyocabinet-1.4.17 LDFLAGS=-L../tokyocabinet-1.4.17 ./configure && make
cd ..
svn co http://svn.coderepos.org/share/lang/c/tdserver/trunk/ tdserver
cd tdserver
make
2. USAGE
See help message by -h option.
./tdserver -h
./tdserver: A server of Tokyo Dystopia
usage:
./tdserver [-host name] [-port num] [-thnum num] [-tout num] [-dmn] [-pid path] [-kl] [-log path] [-ld|-le] [-sid num] [-mask expr] [-unmask expr] [dbname]
3. START DAEMON
tdserver will create td_base directory then listen port 1977 as a HTTP server.
./tdserver -port 1977 td_base
4. ACCESS RESTfully
Three HTTP methods, GET, PUT and DELETE are accepted as RESTful interface.
Try it by Perl as follows.
* Insert (PUT method)
perl -MLWP::UserAgent -MHTTP::Request::Common -e 'print LWP::UserAgent->new->request(PUT "http://localhost:1977/1",Content=>"hello world")->as_string;'This inserts a text "hello world" as a document #1.
ID# must be a positive numeric.
* Fetch (GET method)
perl -MLWP::UserAgent -MHTTP::Request::Common -e 'print LWP::UserAgent->new->request(GET "http://localhost:1977/1")->as_string;'This returns document #1 directly.
* Search (GET method with query string)
perl -MLWP::UserAgent -MHTTP::Request::Common -e 'print LWP::UserAgent->new->request(GET "http://localhost:1977/?q=hello")->as_string;'This searchs documents which contain phrase "hello" and returns ID numbers comma separated.
* Remove (DELETE method)
perl -MLWP::UserAgent -MHTTP::Request::Common -e 'print LWP::UserAgent->new->request(HTTP::Request::Common::DELETE "http://localhost:1977/1")->as_string;'This removes document #1.
Feed backs and patches on CodeRepos are really welcomed.