workerman/redis 键超时订阅不成功,请大家帮看下代码哪里有问题? redis连接正常

0
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Workerman\Redis\Client;
use Workerman\Timer;
use Workerman\Worker;

global $redis, $redis1;

$worker = new Worker("http://0.0.0.0:8111");

function timer_test(){
echo "\ntimer is running.";
global $redis1;
$redis1->setEx("test_key", 5, "123");
$redis1->setEx(
}
function expire_test($redis, $pattern, $channel, $message) {
echo "$pattern, $channel, $message";
}
$worker->onWorkerStart = function($worker) {
global $cfg, $redis1, $redis;

if($worker->id == 0){
Timer::add(10, "timer_test");
}

$redis1 = new Client('redis://127.0.0.1:6379');
$redis2 = new Client('redis://127.0.0.1:6379');

$redis2->psubscribe(array("__keyevent@0__:expired"), "expire_test");
};

$worker->onMessage = function($connection, $data) {
};

Worker::runAll();
已邀请:

walkor

赞同来自:

array("__keyevent@0__:expired") 改成只有字母的字符串试下。比如 array("test")

xinsnd

赞同来自:

redis.conf配置是开启了的,应该是参数的顺序搞错了,我再测一下,感谢!祝新年快乐!

要回复问题请先登录注册