php Symfony2 学说清除缓存
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11826444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Symfony2 doctrine clear cache
提问by morteza kavakebi
I need to clear my doctrine'scache in Symfony 2.
我需要在Symfony 2 中清除我的学说缓存。
There must be some way in command line for clear the cache.
命令行中必须有某种方法来清除缓存。
Or where should I find and delete the files belonging to cache?
或者我应该在哪里找到并删除属于缓存的文件?
回答by amitchhajer
app/console
will list how you can do it
将列出你如何做到这一点
app/console doctrine:cache:clear-metadata
app/console doctrine:cache:clear-query
app/console doctrine:cache:clear-result
for symfony 3+:
对于 symfony 3+:
php bin/console
and list of comand (for copy/past from project directory):
和命令列表(用于从项目目录复制/过去):
php bin/console doctrine:cache:clear-metadata
php bin/console doctrine:cache:clear-query
php bin/console doctrine:cache:clear-result
回答by Antho
If you want to do it within your code (from Doctrine's documentation) :
如果您想在代码中执行此操作(来自Doctrine 的文档):
If you simply want to delete all cache entries you can do so with the deleteAll() method.
<?php $cacheDriver = new \Doctrine\Common\Cache\ArrayCache(); $deleted = $cacheDriver->deleteAll();
如果您只想删除所有缓存条目,您可以使用 deleteAll() 方法。
<?php $cacheDriver = new \Doctrine\Common\Cache\ArrayCache(); $deleted = $cacheDriver->deleteAll();
回答by Oli
In case you use APC, you could also just call the code
如果您使用 APC,您也可以调用代码
<?php
$deleted = apc_clear_cache() && apc_clear_cache('user');
in a php page on the same server. This is what deleteAll() method in Antho's answer does, but you do not depend on the Doctrine Classes. Btw: the complete cache will be flushed - just in case you use it for non-Doctrine stuff.
在同一服务器上的 php 页面中。这就是 Antho 答案中的 deleteAll() 方法所做的,但您不依赖于 Doctrine Classes。顺便说一句:完整的缓存将被刷新 - 以防万一你将它用于非 Doctrine 的东西。
回答by beterthanlife
I thought I was going crazy with doctrine results caching - in the end I had to restart memcached.
我以为我对学说结果缓存快要疯了 - 最后我不得不重新启动 memcached。
回答by lsimonetti
I know the title of this post says Symfony 2, but for those of you coming from google, if you have Symfony 3+ its gonna be:
我知道这篇文章的标题是 Symfony 2,但对于那些来自谷歌的人来说,如果你有 Symfony 3+,它会是:
bin/console
As opposed to:
与之相反:
app/console
回答by Koronos
Maybe is a little late for this, but in my case, doctrine didn't generate the proxy classes in production, for that I change the auto_generate_proxy_classesto true:
也许这有点晚了,但就我而言,学说没有在生产中生成代理类,为此我将其更改auto_generate_proxy_classes为 true:
#symfony2&3 app/config/config.yml
#symfony4 config/packages/doctrine.yaml (by default true since 4.2)
doctrine:
orm:
auto_generate_proxy_classes: true #"%kernel.debug%"

