如何清除Doctrine APC缓存以进行生产? [英] How to clear Doctrine APC cache for production?
问题描述
当我在其中一个实体中添加一列并将其发布以用于生产时,我不得不重启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.
获取刷新刷新缓存的唯一方法是重启我的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
在这种情况下,如何在每次将新的架构更新发布到生产环境时清除APC高速缓存而又不重新启动Apache.如果负载平衡器后面有许多服务器,则情况更糟.
您必须了解,在Apache(或Nginx)下运行的Php与通过命令行运行的Php不同,它们是2个无法通信的Linux进程./p>
因此,即使您可以通过CLI清除缓存,也不会影响Apache下的php.
在Symfony控制器中调用apcu_clear_cache
的最简单方法,或者您可以通过CLI使用Apache Php套接字.
我建议使用类似> http://gordalina.github.io/cachetool/,完美地做到了.
I have this issue when I add a column to one of my entities and release it for production I have to restart Apache in order to clear Doctrine metadata APC/APCU cache.
I have tried all commands below but none worked for me:
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
I get this error message for --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.
The only way I can get it to refresh Doctrine cache is to restart my apache server which can sometimes be an issue.
My cache settings for Doctine in my Symfony project:
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
How can I clear APC cache in this case without restarting Apache each time I release new schema update to production. This is even worse if you have many servers behind a load balancer.
You must understand that Php running under Apache (or Nginx) is different than the Php running via the command line, they are 2 Linux process that cant communicate.
So, even if you can clear the cache via CLI, this will not affect the php under Apache.
The easiest way it to call apcu_clear_cache
inside a Symfony controller, or, you can use the Apache Php socket via the CLI.
I recommend to use a tool like http://gordalina.github.io/cachetool/, which do that perfectly.
这篇关于如何清除Doctrine APC缓存以进行生产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!