拒绝与redis和phpfastcache的连接

zlwx9yxi  于 2021-06-09  发布在  Redis
关注(0)|答案(2)|浏览(374)

我正在尝试设置与的连接 redis 使用 phpfastcache 但我一直都有联系
下面是我的简单代码:

$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

64jmpszr

64jmpszr1#

因此,默认情况下,当使用phpfastcache时,它会连接到主机=“127.0.0.1”,但如果使用docker,则必须将其更改为该容器的主机名才能正常工作。

o2g1uqev

o2g1uqev2#

请检查lib/phpfastcache/drivers/redis/config.php中提供的默认主机和端口是否与redis服务器相同。
您可能还需要使用unix套接字而不是标准连接。

相关问题