如何在Symfony5中为理论配置apcu

问题描述 投票:1回答:1

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

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

升级到Symfony5后,出现错误:

为实体中的缓存“ metadata_cache”配置的“ apc”类型的未知缓存经理“默认”。

将其更改为以下配置时,它可以工作:

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 doctrine symfony5
1个回答
0
投票

我在Symfony 4.4.5中有相同的问题

您应先安装Symfony Cache Component。然后,您应该按以下方式配置缓存池,服务和原则缓存:

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

© www.soinside.com 2019 - 2024. All rights reserved.