当我向实体添加列并发布到生产环境中时,我遇到了这个问题:我必须重新启动Apache才能清除Doctrine元数据APC/APCU缓存。
我尝试了下面所有的命令,但都没有成功:
php -r "apc_clear_cache();"
php -r "apcu_clear_cache();"
sudo php app/console doctrine:cache:clear-metadata
sudo php app/console doctrine:cache:clear-query
sudo php app/console doctrine:cache:clear-result
我在使用 --env=prod 时出现了以下错误信息。
sudo php app/console doctrine:cache:clear-metadata --env=prod
sudo php app/console doctrine:cache:clear-query --env=prod
sudo php app/console doctrine:cache:clear-result --env=prod
[LogicException]
Cannot clear APC Cache from Console, its share in the Web server memory and not accessible from the CLI.
我能想到的刷新Doctrine缓存的唯一方法是重启我的Apache服务器,这有时可能会产生问题。
在我的Symfony项目中,Doctine的缓存设置如下:
doctrine:
orm:
metadata_cache_driver: apc
result_cache_driver: apc
query_cache_driver: apc
second_level_cache:
enabled: true
log_enabled: false
region_cache_driver: apc
如何在不重启Apache的情况下清除APC缓存,每次发布新的模式更新到生产环境中。如果您有许多服务器在负载均衡器后面,这种情况会更糟。