|
...
|
...
|
@@ -15,6 +15,7 @@ class RedisCli |
|
|
|
->withAuth($password)
|
|
|
|
->withDbIndex($dbIndex)
|
|
|
|
->withTimeout($timeout)
|
|
|
|
->withReadTimeout($timeout)
|
|
|
|
,$num //默认64个连接池
|
|
|
|
);
|
|
|
|
}
|
|
...
|
...
|
@@ -129,4 +130,18 @@ class RedisCli |
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function psubscribe($channels,callable $onMessage)
|
|
|
|
{
|
|
|
|
$redis = $this->pool->get();
|
|
|
|
try {
|
|
|
|
$res = $redis->psubscribe($channels,function($redis, $pattern, $channel, $message)use($onMessage){
|
|
|
|
call_user_func($onMessage, $pattern, $redis, $channel, $message);
|
|
|
|
});
|
|
|
|
}catch (\RedisException $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$this->pool->put($redis);
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|