HandlerSocket 测试报告
use strict;
usewarnings;
use Net::HandlerSocket;
#1.1 establishing a connection
my $args = { host => '127.0.0.1', port => 9999 };
my $hs = new Net::HandlerSocket($args);
#1.2 open index
my $res = $hs->open_index(0, 'test', 't1', 'PRIMARY', 'id,k,c,pad');
die $hs->get_error() if $res != 0;
#2. insert
while (1)
{
my $tmp_i = sprintf("%d", rand() * 10000000);
$res = $hs->execute_insert(0, [ '0',"$tmp_i",'abcy','aasfasdyyy' ]);
my $insert_id = $res->[1];
my $ret = $res->[0];
}
#4. closing the connection
15.
HandlerSocket 测试报告
$hs->close();
2.3.3 更新记录
#!/usr/bin/perl
usestrict;
use warnings;
use Net::HandlerSocket;
#1.1 establishing a connection
my $args = { host => '127.0.0.1', port => 9999 };
my $hs = new Net::HandlerSocket($args);
#2 open index
my $res = $hs->open_index(0, 'test', 't1', 'PRIMARY', 'k');
die $hs->get_error() if $res != 0;
#3. update
#$hs->execute_single(0, '=', [ '270337481' ] , 1, 0, 'U', [ '1806176' ]);
#或者
$hs->execute_update(0, '=', [ '270337481' ] , 1, 0, [ '1806177' ]);
16.
HandlerSocket 测试报告
#4. closingthe connection
$hs->close();
2.3.4 删除记录
#!/usr/bin/perl
use strict;
use warnings;
use Net::HandlerSocket;
#1 establishing a connection
my $args = { host => '127.0.0.1', port => 9999 };
my $hs = new Net::HandlerSocket($args);
#2 open index
my $res = $hs->open_index(0, 'test', 't1', 'PRIMARY', 'k');
die $hs->get_error() if $res != 0;
#3. delete
#$hs->execute_single(0, '=', [ '270337481' ] , 1, 0, 'D');