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
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

接收消息的回调函数。除了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年前

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