在我的 config_prod.yml
文件中,我有以下配置。在哪里可以配置 Redis 驱动程序——诸如 unix 套接字(或主机)、数据库编号等选项?
doctrine:
orm:
metadata_cache_driver: redis
query_cache_driver: redis
result_cache_driver: redis
最佳答案
这里是 symfony 4.4/5 的实现方式,因为文档有点困惑。
首先需要设置缓存池:
#config/packages/cache.yaml
framework:
cache:
default_redis_provider: 'redis://localhost' # or '%env(resolve:REDIS_URL)%'
pools:
custom_cache_pool:
adapter: cache.adapter.redis
然后像这样将这个池用于学说结果缓存:
#config/packages/doctrine.yaml
doctrine:
...
orm:
result_cache_driver:
type: pool
pool: custom_cache_pool
关于symfony - 如何在 Symfony 应用程序中为 Doctrine 配置 Redis 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45274706/