laravel Redis扩展 发布订阅是不是有bug呀

出现的问题:在使用psubscribe或者subscribe的时候不能设置redis字符串的使用
我的代码

Redis::psubscribe(['test*'], function ($message, $channel) {
            Redis::set($channel, $message); // 这一句没有效果
            if ($channel == 'test-channel') {
                echo 'test-channel';
            } else {
                echo $channel . ':' . $message;
            }
        });

Redis源码:


/**
 * Subscribe to a set of given channels with wildcards. * * @param array|string  $channels
 * @param \Closure  $callback
 * @return void
 */public function psubscribe($channels, Closure $callback)
{
  $this->client->psubscribe((array) $channels, function ($redis, $pattern, $channel, $message) use ($callback) {
  $callback($message, $channel);
  });
}


/**
 * Subscribe to a set of given channels for messages. * * @param array|string  $channels
 * @param \Closure  $callback
 * @return void
 */public function subscribe($channels, Closure $callback)
{
  $this->client->subscribe((array) $channels, function ($redis, $channel, $message) use ($callback) {
  $callback($message, $channel);
  });
}

当中第二个参数闭包不能使用$redis

984054610
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

接收消息的回调函数。除了SUBSCRIBE、PSUBSCRIBE、UNSUBSCRIBE、PUNSUBSCRIBE这4条命令以外,其它命令都不能使用。

segmentfault.com/a/119000001028736...

4年前 评论
Lee丶 3年前
讨论数量: 2

接收消息的回调函数。除了SUBSCRIBE、PSUBSCRIBE、UNSUBSCRIBE、PUNSUBSCRIBE这4条命令以外,其它命令都不能使用。

segmentfault.com/a/119000001028736...

4年前 评论
Lee丶 3年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!