gpt4 book ai didi

php - Symfony 使用 Redis 作为默认缓存编译容器

转载 作者:IT王子 更新时间:2023-10-29 06:04:53 26 4
gpt4 key购买 nike

我有一个 Symfony 应用程序,我想使用 Redis 作为缓存系统。 Symfony 开箱即用的默认缓存系统是文件系统缓存。

从文档中我了解到 Symfony 中有两个命名缓存; cache.appcache.system 所以我使用以下 cache.yaml 将两者都设置为 Redis:

framework:
cache:
# Put the unique name of your app here: the prefix seed
# is used to compute stable namespaces for cache keys.
prefix_seed: myteam/myapp

default_redis_provider: "redis://redis:6379"

# The app cache caches to the filesystem by default.
# Other options include:

# cache.app via Redis
app: cache.adapter.redis

# cache.system also
system: cache.adapter.redis

完成此操作后,我加载了一个示例页面并监控了缓存文件夹。我发现文件仍在缓存文件夹中创建,即使 key 是在 Redis 中创建的。

我知道 Symfony 不建议弄乱内核在文件缓存中创建的文件,但即使是 cache/prod/Containerxxxxx 文件夹也被写入。

在不属于应用程序或系统的文件夹中可能缓存了什么?我错过了另一个命名缓存吗?

最佳答案

cache/prod/Containerxxxxx 中的文件是编译后的容器文件。

这些总是写入您的文件系统,永远不会写入其他二级缓存系统。

如果不从容器中获取信息,Symfony 一开始就不知道如何访问 Redis,容器在编译和构建时总是缓存到文件系统。

  • cache.system 用于注释、序列化程序和验证等;但不是编译容器本身。

  • cache.app 是应用程序缓存,如果您输入提示 CacheInterface,它可供您在您的应用程序中使用或服务方法中的 Psr\\Cache\\CacheItemPoolInterface

总而言之,没有其他缓存可以配置,因此 Symfony 会将已编译的容器存储在那里。这些文件是代码,存储在文件系统中。

关于php - Symfony 使用 Redis 作为默认缓存编译容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56739759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com