php - 与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
解决方案
因此,默认情况下,当使用 phpfastcache 时,它会连接到 host = "127.0.0.1" 但如果您使用 docker,则必须将其更改为该容器的主机名才能正常工作。
推荐阅读
- python - Python 3.x 中 __getattr__ 特殊方法破坏 inspect.getmembers() 的解决方法
- java - 调用某些方法时如何忽略键盘上的按键?
- windows - 使用 NSIS 写入注册表项失败
- java - 如何在休眠中创建相关子查询
- c++ - 如何使用 CFileDialog 获取包含非 ascii 字符的文件路径
- python - 类型错误:__call__() 缺少 1 个必需的位置参数:“输入”
- regex - 从perl中的字符串中提取子字符串
- azure - Cosmos DB - 是否有自动增量字段的方法?
- android - 如何在编辑文本中添加人高,例如(5'11)
- javascript - YouTube Api 仅在硬重新加载时触发