php - Symfony - Doctrine cache configuration error
I try to define cache for queries & results with Doctrine in a Symfony 5.4 project but I have an error message when my application is in production environment (this error is not present in development environnement).
Message:
Circular reference detected for service "doctrine.result_cache_pool", path: "doctrine.result_cache_pool -> doctrine.system_cache_pool.compatibility_layer -> doctrine.system_cache_pool -> doctrine.result_cache_pool.compatibility_layer -> doctrine.result_cache_pool".
doctrine.yaml file in config/packages/prod directory:
doctrine:
orm:
metadata_cache_driver:
type: pool
pool: doctrine.system_cache_pool
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
services:
doctrine.system_cache_pool:
class: Doctrine\Common\Cache\Psr6\DoctrineProvider
public: false
arguments:
- '@doctrine.orm.default_result_cache'
doctrine.result_cache_pool:
class: Doctrine\Common\Cache\Psr6\DoctrineProvider
public: false
arguments:
- '@doctrine.orm.default_metadata_cache'
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system
I have read the official documentation from Symfony but the part about "services" section is missing.
Answer
Solution:
Have you cleared your cache in prod ? or delete the prod folder which is in var/cache
Source