首页 > 解决方案 > 与redis和phpfastcache的连接拒绝

问题描述

我正在尝试设置要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

标签: phpcachingredisphpfastcache

解决方案


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


推荐阅读