如何在 Symfony5 中为 doctrine 配置 apcu
How to configure apcu for doctrine in Symfony5
在 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 后出现错误:
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:
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.
在 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 后出现错误:
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:
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.