php - 使用 symfony 配置 Phpredis 客户端时遇到问题
问题描述
我在使用 Snc\RedisBundle 捆绑配置 Phpredis 时遇到问题。我正在使用 symfony 4.4 版。当我安装Predis 客户端时,如果我安装 Snc\RedisBundle,它会删除 Snc\RedisBundle,Predis 也会发生同样的情况。默认情况下 Snc\RedisBundle 包使用 PhpRedis 客户端。不知道我在配置中做错了什么,这导致了这个问题。
snc_redis.yaml
snc_redis:
class:
phpredis_client:
'Snc\RedisBundle\Client\Phpredis\Client'
clients:
default:
type: phpredis
alias: default
dsn: redis://127.0.0.1:6379 # (*)
logging: '%kernel.debug%'
options:
replication: sentinel
service: mymaster
parameters:
database: 1
password:
服务.yaml
services:
Snc\RedisBundle\Client\Phpredis\Client: '@snc_redis.default'
RedisController.php
use Snc\RedisBundle\Client\Phpredis\Client;
/** @var Client */
private $redisClient;
public function __construct(Client $client)
{
$this->redisClient = $client;
}
/**
* @Route("/keys", name="keys")
*/
public function indexAction()
{
$redisKeys = $this->redisClient->keys('*');
return $this->json(['keys' => $redisKeys]);
}
我收到错误警告:找不到类 'Container97esFst\Client_541ffe9'
解决方案
推荐阅读
- angular - 即使在Angular中刷新后如何保存数据
- java - 如何从 HTML 生成 PDF 并在 Java 代码中添加链接参考(任何网站)?
- php - 我正在尝试将我的 php 表单中的数据插入 mysql 数据库,但它给了我错误
- azure - yml 作业与代码中的 Azure ML docker env 参数
- python - 每个箱线图上的 Seaborn 分组箱线图符号
- wordpress - 设置按钮“仅登录或仅注销”,
- android-studio - Firebase Fire 存储数据库如何在文本框中显示添加的数据?
- python - boto3 下载 mp4 而不是流式传输
- rethinkdb - 合并子数组并排序
- go - ssh channel Fprintln Line Disorderly go ssh channel writer