如何在 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: SymfonyComponentCacheDoctrineProvider
public: false
arguments:
- '@doctrine.result_cache_pool'
doctrine.system_cache_provider:
class: SymfonyComponentCacheDoctrineProvider
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
以上配置取自 这里.
这篇关于如何在 Symfony5 中为学说配置 apcu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!