vali 6 年之前
父节点
当前提交
c455fa3ef6
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. 7 3
      datainf/logic/HttpServerRedisToSql.php

+ 7 - 3
datainf/logic/HttpServerRedisToSql.php

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