我想在不同的环境中为学说缓存设置默认的缓存生命周期/超时。
php bin/console config:dump-reference doctrine
仅显示在实体管理器区域的高级配置中相当深入地设置生命周期的选项,我不想在其中乱七八糟。我不敢相信没有地方可以为数据库结果缓存设置一般值。
真的没有选项可以在配置文件中设置缓存的默认超时吗?
当前配置/测试/doctrine.yaml:
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.app
doctrine.system_cache_pool:
adapter: cache.system
我就是这样做的...
framework:
cache:
default_memcached_provider: 'memcached://localhost:...'
pools:
doctrine.result_cache_pool:
adapter: cache.adapter.memcached
public: false
default_lifetime: 86400
在 config/packages/prod/doctrine.yaml 中 需要更改为:
doctrine:
orm:
auto_generate_proxy_classes: false
metadata_cache_driver:
type: service
id: doctrine.system_cache_pool
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system