【问题标题】:connection refuse with redis and phpfastcacheredis 和 phpfastcache 拒绝连接
【发布时间】:2020-06-28 22:40:52
【问题描述】:

我正在尝试使用phpfastcache 设置与redis 的连接,但我不断收到连接拒绝

这是我的简单代码:

        $defaultDriver = 'Redis';
        $Psr16Adapter = new Psr16Adapter($defaultDriver);

        if(!$Psr16Adapter->has('foo'))
        {
            $Psr16Adapter->set('foo', 'test', 300);
        }
        else
        {
            $data = $Psr16Adapter->get('foo');
        }

现在我得到的是:

消息:Redis 连接失败并出现以下错误消息:/var/www/html/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Drivers/Redis/Driver.php 中的第 77 行“连接被拒绝”

文件名:/var/www/html/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Pool/DriverBaseTrait.php

行号:76

【问题讨论】:

    标签: php caching redis phpfastcache


    【解决方案1】:

    所以默认情况下,使用 phpfastcache 时,它​​会连接到 host = "127.0.0.1",但如果您使用 docker,则必须将其更改为该容器的主机名才能正常工作。

    【讨论】:

      【解决方案2】:

      请检查 lib/Phpfastcache/Drivers/Redis/Config.php 中提供的默认主机和端口是否与您的 Redis 服务器相同。

      您可能还需要使用 Unix 套接字而不是标准连接。

      【讨论】:

        猜你喜欢
        • 2021-01-24
        • 2017-07-10
        • 2016-02-14
        • 2018-09-29
        • 2019-01-22
        • 2021-10-22
        • 2021-07-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多