首页 > 解决方案 > 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

标签: phplaravelredis

解决方案


推荐阅读