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 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

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

segmentfault.com/a/119000001028736...

3年前 评论
curry丶 2年前
讨论数量: 2

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

segmentfault.com/a/119000001028736...

3年前 评论
curry丶 2年前

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