如何在Symfony5中为理论配置apcu [英] How to configure apcu for doctrine in Symfony5
问题描述
在Symfony4中,我使用以下配置进行教义apcu缓存:
In Symfony4 I was using the following configuration for doctrine apcu caching:
doctrine:
orm:
auto_mapping: true
auto_generate_proxy_classes: false
metadata_cache_driver: apcu
query_cache_driver: apcu
result_cache_driver: apcu
升级到Symfony5后,出现错误:
After upgrading to Symfony5 I am getting an error:
为实体中的缓存"metadata_cache"配置的类型为"apc"的未知缓存 经理默认".
Unknown cache of type "apc" configured for cache "metadata_cache" in entity manager "default".
将其更改为以下配置时,它将起作用:
When changing the it to the following configuration it works:
doctrine:
orm:
auto_mapping: true
auto_generate_proxy_classes: false
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
但是我现在使用哪种缓存?以及如何将其切换到apcu?
But what kind of cache am I using now? And how can I switch it to apcu?
推荐答案
我在Symfony 4.4.5中遇到了相同的问题
I had the same problem in Symfony 4.4.5
您应该首先安装 Symfony缓存组件.然后,您应按以下方式配置缓存池,服务和学说缓存:
You should first install the Symfony Cache Component. Then, you should configure cache pools, services and doctrine cache as follows:
doctrine:
orm:
auto_generate_proxy_classes: false
metadata_cache_driver:
type: service
id: doctrine.system_cache_provider
query_cache_driver:
type: service
id: doctrine.system_cache_provider
result_cache_driver:
type: service
id: doctrine.result_cache_provider
services:
doctrine.result_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.result_cache_pool'
doctrine.system_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.system_cache_pool'
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.adapter.apcu
doctrine.system_cache_pool:
adapter: cache.adapter.apcu
以上配置取自 查看全文