首页 > 数据库 > > Tokyo Tyrant基本规范(5)--教程
[terminal-1]$ ttserver
[terminal-2]$ tcrmgr put localhost one first [terminal-2]$ tcrmgr put localhost two second [terminal-2]$ tcrmgr put localhost three third
[terminal-2]$ tcrmgr mget localhost one two three
[terminal-1]$ ttserver casket.tch
[terminal-2]$ tcrmgr put localhost one first [terminal-2]$ tcrmgr put localhost two second [terminal-2]$ tcrmgr put localhost three third
[terminal-1]$ ttserver casket.tch
[terminal-2]$ tcrmgr mget localhost one two three
[terminal-1]$ rm casket.tch
[terminal-1]$ ttserver -dmn -pid /tmp/ttserver.pid /tmp/casket.tch
[terminal-1]$ kill -TERM `cat /tmp/ttserver.pid`
[terminal-1]$ ttserver casket.tch
[terminal-2]$ tcrmgr put localhost one first [terminal-2]$ tcrmgr put localhost two second [terminal-2]$ tcrmgr put localhost three third
[terminal-2]$ tcrmgr copy localhost backup.tch
[terminal-1]$ rm casket.tch
[terminal-1]$ cp backup.tch casket.tch [terminal-1]$ ttserver casket.tch
[terminal-2]$ tcrmgr mget localhost one two three
[terminal-1]$ rm casket.tch backup.tch
[terminal-1]$ mkdir ulog [terminal-1]$ ttserver -ulog ulog casket.tch
[terminal-2]$ tcrmgr put localhost one first [terminal-2]$ tcrmgr put localhost two second [terminal-2]$ tcrmgr put localhost three third
[terminal-1]$ rm casket.tch
[terminal-1]$ mv ulog ulog-back [terminal-1]$ mkdir ulog [terminal-1]$ ttserver -ulog ulog casket.tch
[terminal-2]$ tcrmgr restore localhost ulog-back
[terminal-2]$ tcrmgr mget localhost one two three
[terminal-1]$ rm -rf casket.tch ulog ulog-back
[terminal-1]$ mkdir ulog-1 [terminal-1]$ ttserver -port 1978 -ulog ulog-1 -sid 1 casket-1.tch
[terminal-2]$ mkdir ulog-2 [terminal-2]$ ttserver -port 1979 -ulog ulog-2 -sid 2 -mhost localhost -mport 1978 -rts 2.rts casket-2.tch
[terminal-3]$ tcrmgr put -port 1978 localhost one first [terminal-3]$ tcrmgr put -port 1978 localhost two second [terminal-3]$ tcrmgr put -port 1978 localhost three third
[terminal-2]$ tcrmgr mget -port 1978 localhost one two three [terminal-2]$ tcrmgr mget -port 1979 localhost one two three
[terminal-1]$ rm casket-1.tch
[terminal-2]$ ttserver -port 1979 -ulog ulog-2 -sid 2 casket-2.tch
[terminal-1]$ mkdir ulog-3 [terminal-1]$ ttserver -port 1980 -ulog ulog-3 -sid 3 -mhost localhost -mport 1979 -rts 3.rts casket-3.tch
[terminal-2]$ tcrmgr mget -port 1979 localhost one two three [terminal-2]$ tcrmgr mget -port 1980 localhost one two three
[terminal-1]$ rm -rf casket-1.tch ulog-1 1.rts [terminal-2]$ rm -rf casket-2.tch ulog-2 2.rts [terminal-1]$ rm -rf casket-3.tch ulog-3 3.rts
#! /bin/sh srcpath="$1" destpath="$1.$2" rm -f "$destpath" cp -f "$srcpath" "$destpath"
[terminal-1]$ mkdir ulog-1 [terminal-1]$ ttserver -port 1978 -ulog ulog-1 -sid 1 casket-1.tch
[terminal-2]$ tcrtest write -port 1978 localhost 10000
[terminal-2]$ tcrmgr list -port 1978 -pv localhost
[terminal-2]$ tcrmgr copy -port 1978 localhost '@./ttbackup.sh'
[terminal-2]$ ls [terminal-2]$ cp casket-1.tch.xxxxx casket-2.tch [terminal-2]$ echo xxxxx > 2.rts [terminal-2]$ mkdir ulog-2 [terminal-2]$ ttserver -port 1979 -ulog ulog-2 -sid 2 -rts 2.rts casket-2.tch
[terminal-3]$ tcrmgr put -port 1978 localhost one first [terminal-3]$ tcrmgr put -port 1978 localhost two second [terminal-3]$ tcrmgr put -port 1978 localhost three third
[terminal-3]$ tcrmgr inform -port 1978 localhost [terminal-3]$ tcrmgr inform -port 1979 localhost
[terminal-3]$ tcrmgr setmst -port 1979 -mport 1978 localhost localhost
[terminal-3]$ tcrmgr inform -port 1979 -st localhost
[terminal-1]$ rm -rf casket-1.tch casket-1.tch.* ulog-1 1.rts ttbackup.sh [terminal-2]$ rm -rf casket-2.tch ulog-2 2.rts
[terminal-1]$ ttserver -ext test.lua
[terminal-2]$ tcrmgr ext localhost fibonacci 1 [terminal-2]$ tcrmgr ext localhost fibonacci 2 [terminal-2]$ tcrmgr ext localhost fibonacci 3 [terminal-2]$ tcrmgr ext localhost fibonacci 4 [terminal-2]$ tcrmgr ext localhost fibonacci 5 [terminal-2]$ tcrmgr ext localhost fibonacci 6
[terminal-2]$ tcrmgr ext localhost fibnext [terminal-2]$ tcrmgr ext localhost fibnext [terminal-2]$ tcrmgr ext localhost fibnext [terminal-2]$ tcrmgr ext localhost fibnext [terminal-2]$ tcrmgr ext localhost fibnext [terminal-2]$ tcrmgr ext localhost fibnext
use Cache::Memcached;
my $memd = Cache::Memcached->new();
$memd->set_servers(['localhost:1978']);
$memd->set('one', 'first');
$memd->set('two', 'second');
$memd->set('three', 'third');
my $val = $memd->get('one');
printf("one: %s\n", $val);
$val = $memd->get_multi('one', 'two', 'three');
printf("one: %s\n", $val->{one});
printf("two: %s\n", $val->{two});
printf("three: %s\n", $val->{three});
$memd->delete('one');use LWP::UserAgent;
my $ua = LWP::UserAgent->new(keep_alive => 1);
my $baseurl = 'http://localhost:1978/';
my $req;
$req = HTTP::Request->new(PUT => $baseurl . 'one', [], 'first');
$ua->request($req);
$req = HTTP::Request->new(PUT => $baseurl . 'two', ["X-TT-PDMODE" => 1], 'second');
$ua->request($req);
$req = HTTP::Request->new(PUT => $baseurl . 'three', ["X-TT-PDMODE" => 2], 'third');
$ua->request($req);
$req = HTTP::Request->new(GET => $baseurl . 'one');
my $res = $ua->request($req);
if($res->is_success()){
printf("%s\n", $res->content());
}
$req = HTTP::Request->new(DELETE => $baseurl . 'one');
$res = $ua->request($req);
$req = HTTP::Request->new(POST => $baseurl . 'foo',
["X-TT-XNAME" => "echo", "X-TT-XOPTS" => 1], 'bar');
$res = $ua->request($req);
if($res->is_success()){
printf("%s\n", $res->content());
}[terminal-1]$ ttserver -ext ttexpire.lua -extpc expire 1.0 "casket.tct#idx=x:dec#dfunit=8"
[terminal-2]$ now=`date +%s` for((i=1;i<=60;i++)); do tcrmgr put -sep '|' localhost "$i" "x|$((now+i))" done
[terminal-2]$ tcrmgr list -pv -sep '|' localhost
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70000523/viewspace-3144358/ ,如需转载,请注明出处,否则将追究法律责任。