go(function () use ($options, $phoneNum, $code) {
$redis = new \Swoole\Coroutine\Redis();
$redis->connect(config('redis.host'), config('redis.port'));
$redis->auth($options['password']);
$redis->setDefer();
$redis->set(SwooleRedis::smsKey($phoneNum), $code, config('redis.expir_time'));
$result = $redis->recv();
var_dump($result);
});
swoole2.x适配包括thinkphp5.1.5及以前的,我不清楚为什么老师没写go能够运行,我们就不可以。
我设置了密码的,密码auth认证一定要在connect之后。想要连接成功,我建议使用go()协程。如上头代码
其他的。不懂代码可以找我。