|
@@ -46,9 +46,8 @@ class HttpServerRedisToSql
|
|
|
if (!$serv->taskworker) {
|
|
if (!$serv->taskworker) {
|
|
|
ModelBase::init();
|
|
ModelBase::init();
|
|
|
|
|
|
|
|
- $obj = $this;
|
|
|
|
|
- Swoole\Timer::tick(500, function ($id) use ($obj) {
|
|
|
|
|
- $obj->BatchSqlRedisToDB();
|
|
|
|
|
|
|
+ Swoole\Timer::tick(500, function ($id) {
|
|
|
|
|
+ $this->BatchSqlRedisToDB();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -72,6 +71,8 @@ class HttpServerRedisToSql
|
|
|
{
|
|
{
|
|
|
$redisconfig = $this->redisonfig;
|
|
$redisconfig = $this->redisonfig;
|
|
|
go(function () use ($redisconfig) {
|
|
go(function () use ($redisconfig) {
|
|
|
|
|
+ $rand = mt_rand(10000, 99999);
|
|
|
|
|
+ echo "单个线程开始时间:$rand " . microtime(true) . "\n";
|
|
|
$redis = new Swoole\Coroutine\Redis();
|
|
$redis = new Swoole\Coroutine\Redis();
|
|
|
$ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
|
|
$ret = $redis->connect($redisconfig['host'], $redisconfig['port']);
|
|
|
if (!$ret) {
|
|
if (!$ret) {
|
|
@@ -110,6 +111,9 @@ class HttpServerRedisToSql
|
|
|
$sqlstr = implode(";", $batchsql);
|
|
$sqlstr = implode(";", $batchsql);
|
|
|
$pdo->exec($sqlstr);
|
|
$pdo->exec($sqlstr);
|
|
|
}
|
|
}
|
|
|
|
|
+ $redis->close();
|
|
|
|
|
+
|
|
|
|
|
+ echo "单个线程结束时间:$rand " . microtime(true) . "\n";
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
|
});
|
|
});
|