Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 doctrine clear cache

I need to clear my doctrine's cache in Symfony.

There must be some way in command line for clear the cache.

Or where should I find and delete the files belonging to cache?

like image 635
morteza kavakebi Avatar asked Aug 06 '12 10:08

morteza kavakebi


People also ask

How do I clear my doctrine cache?

From the Doctrine command line you can run the following commands: To clear the query cache use the orm:clear-cache:query task. To clear the metadata cache use the orm:clear-cache:metadata task. To clear the result cache use the orm:clear-cache:result task.

What is doctrine cache?

Doctrine Cache is a library that provides an interface for caching data. It comes with implementations for some of the most popular caching data stores.


2 Answers

For Symfony 3+:

 php bin/console 

will list all commands, the following are relevant for cache:

 php bin/console doctrine:cache:clear-metadata   php bin/console doctrine:cache:clear-query    php bin/console doctrine:cache:clear-result 

Before Symfony 3:

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  
like image 70
amitchhajer Avatar answered Oct 01 '22 04:10

amitchhajer


If you want to do it within your code (from Doctrine's documentation) :

If you simply want to delete all cache entries you can do so with the deleteAll() method.

$cacheDriver = new \Doctrine\Common\Cache\ArrayCache(); $deleted = $cacheDriver->deleteAll(); 
like image 39
Antho Avatar answered Oct 01 '22 06:10

Antho