diff --git a/app/command/ApiLogCommand.php b/app/command/ApiLogCommand.php index 62d2b72c..d4818d5a 100644 --- a/app/command/ApiLogCommand.php +++ b/app/command/ApiLogCommand.php @@ -41,8 +41,9 @@ class ApiLogCommand extends Command // 如果是 MySQL 2006 错误,则重连后再执行 if (strpos($e->getMessage(), '2006 MySQL server has gone away') !== false) { Log::warning('MySQL connection lost, reconnecting...'); - Db::disconnect(); // 清理旧连接 - Db::reconnect(); // 重新连接 + Db::purge(); + // Db::disconnect(); // 清理旧连接 + // Db::reconnect(); // 重新连接 ApiLogModel::create($logData); // 重试一次 } else { throw $e; diff --git a/app/command/TestCommand.php b/app/command/TestCommand.php new file mode 100644 index 00000000..26eeaec5 --- /dev/null +++ b/app/command/TestCommand.php @@ -0,0 +1,42 @@ +setName('test') + ->setDescription('the test command'); + } + /** + * Execute the console command. + * + * @param Input $input + * @param Output $output + * @return void + */ + protected function execute(Input $input, Output $output) + { + $cacheCode = Cache::store('redis')->keys('api_log'); + dd($cacheCode); + $param['nation'] = '81'; + $param['phone'] = '8057252138'; + $mobile = $param['nation'] . ltrim($param['phone'], '0'); + + $smsKey = 'DB:USER:UNLOGIN:SMS_CODE:' . $mobile; + $cacheCode = Cache::store('redis')->get($smsKey); + dd($cacheCode); + + } +} diff --git a/config/console.php b/config/console.php index 119f6ac7..5ef2d1bf 100644 --- a/config/console.php +++ b/config/console.php @@ -6,5 +6,6 @@ return [ // 指令定义 'commands' => [ \app\command\ApiLogCommand::class, + \app\command\TestCommand::class, ], ];