gpt4 book ai didi

symfony - 如何在 Symfony5 中为 Doctrine 配置 apcu

转载 作者:行者123 更新时间:2023-12-03 19:42:45 27 4
gpt4 key购买 nike

在 Symfony4 中,我使用以下配置来进行 Doctrine apcu 缓存:

doctrine:
orm:
auto_mapping: true
auto_generate_proxy_classes: false
metadata_cache_driver: apcu
query_cache_driver: apcu
result_cache_driver: apcu

升级到 Symfony5 后,出现错误:

Unknown cache of type "apc" configured for cache "metadata_cache" in entity manager "default".



将其更改为以下配置时,它可以工作:
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?

最佳答案

我在 Symfony 4.4.5 中遇到了同样的问题

您应该首先安装 Symfony Cache Component .然后,您应该按如下方式配置缓存池、服务和 Doctrine 缓存:

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

以上配置取自 here .

关于symfony - 如何在 Symfony5 中为 Doctrine 配置 apcu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60862410/

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