php - Redis laravel 不发布频道
问题描述
我正在尝试使用 Laravel 在 redis 频道中发布消息。当我在频道中发布消息不起作用时,响应返回为 0,并且在 redis-cli 中我看不到该消息。
我把代码放在这里:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Redis;
class publishController extends Controller
{
public function test ()
{
$result = Redis::publish('test', json_encode(['mss' => 'here the message']));
return $result;
}
}
这是 cache.php 文件
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
],
这是我的 .env 文件
REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379
解决方案
推荐阅读
- php - 我如何将 PHP 中的数组转换为使用 AnyChart
- linux - Debian 9,libm 和“符号 __get_cpu_features,版本 GLIBC_PRIVATE 未定义”
- python - 用于二叉搜索树的递归 PrintTree() 方法无法正确打印
- r - 具有 NA 的 R cummax 函数
- r - “survivalsvm”预测什么?
- c++ - 喷溅结构
- c - 双指针内存分配访问问题与没有索引的指针算术
- python - scrapy中的下一个按钮
- java - Java 与 MongoDB 连接问题 - 获取 SQL 异常
- python - Spyder 远程内核处理