redis - 清除缓存时删除redis键
问题描述
项目配置:symfony 5。
我将缓存配置为使用redis,config\packages\cache.yml
就像这样
framework:
cache:
prefix_seed: myAppPrefix_
app: cache.adapter.redis
system: cache.adapter.filesystem
default_redis_provider: '%env(REDIS_URL)%'
当我运行时php bin/console cache:clear --env=dev
,redis 密钥不会被删除,也不会过期。
该cache:clear
命令不应该删除或使密钥过期?
我可以删除所有与我的应用前缀匹配的密钥吗?
谢谢你的帮助
解决方案
我没有找到任何确认 cache:clear 应该清除链接到我的配置的 redis 键的参考。
最后,我创建了一个命令(注入“AdapterInterface”)以使用该代码清理它们:
public function __construct(AdapterInterface $cache)
{
...
$this->cache= $cache;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->redis->clear();
}
小心,在 Windows 上它不起作用,因为 Redis 版本在 RedisTrait:356 中为空
推荐阅读
- javascript - 进行切换以向具有特定类的所有元素添加/删除类
- python-3.x - 我需要一种最简单的方法来使用 python 脚本更改文件的内容
- java - 在 SAP Cloud SDK 中使用 Java 为 SFSF 生成 VDM:生成的 URI 错误
- junit - Mockito 核心匹配器-GreaterThan
- apache-spark - 我收到此错误“对象 ml 不是包 org.apache.spark 的成员”
- php - 如何安装 mcrypt PHP 模块
- python - 从 html 表单中获取图像的 Python 问题
- python - 需要预先加载模块时在 VS 代码中运行 pytest
- php - 批量插入 Eloquent Collection - Lumen/Laravel
- amazon-web-services - Terraform:导入现有的互联网网关并附加到 vpc