***<?php
$http = new swoole_http_server(“10.0.70.24”, 9501);
http−>on(′request′,function(http->on('request', function (http−>on(′request′,function(request, $response) {
echo time();
$swoole_mysql = new SwooleCoroutineMySQL();
$swoole_mysql->connect([
‘host’ => ‘127.0.0.1’,
‘port’ => 3306,
‘user’ => ‘root’,
‘password’ => ‘root’,
‘database’ => ‘ydstest’,
]);
$swoole_mysql2 = new SwooleCoroutineMySQL();
$swoole_mysql2->connect([
‘host’ => ‘127.0.0.1’,
‘port’ => 3306,
‘user’ => ‘root’,
‘password’ => ‘root’,
‘database’ => ‘ydstest’,
]);
$res = $swoole_mysql->query('select sleep(5),id from test_user ',10);
$rs = $swoole_mysql2->query(‘select sleep(10) from test_user where id=1’,15);
$response->header(‘Content-Type’,‘text/plain’);
response−>end(jsonencode(response->end(json_encode(response−>end(jsonencode(rs));
echo time();
});
$http->start();
为什么 这段代码执行时间是 15秒 不是预料的10秒呢