Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing Symfony cache for another application

I would like to clear my frontend application's cache from an action in my backend application.

How can I achieve this?

like image 214
Erland Wiencke Avatar asked Aug 25 '09 11:08

Erland Wiencke


People also ask

When should I clear the cache in Symfony?

During application development, you have to clear the cache in various situations: When you create a new class: Adding a class to an autoloading directory (one of the project’s lib/ folders) is not enough to have symfony find it automatically.

What are cache tags in Symfony?

Later, when the item is retrieved, Symfony stores the item automatically in all the missing pools. In applications with many cache keys it could be useful to organize the data stored to be able to invalidate the cache more efficiently. One way to achieve that is to use cache tags.

How do I clear only selective parts of the cache?

Listing 18-14 – Clearing Only Selective Parts of the Cache You can also remove files by hand in the cache/ directory, or clear template cache files selectively from the action with the $cacheManager->remove () method, as described inChapter 12 1. We can use $cacheManager->remove () to clear cache after we deployed a new version product.

How do I use a chain of adapters in Symfony?

To get the best of both worlds you may use a chain of adapters. A cache chain combines several cache pools into a single one. When storing an item in a cache chain, Symfony stores it in all pools sequentially. When retrieving an item, Symfony tries to get it from the first pool.


1 Answers

I believe the proper way to do this in symfony 1.2 is as follows:

sfContext::switchTo('frontend'); //switch to the environment you wish to clear
sfContext::getInstance()->getViewCacheManager()->getCache()->clean(sfCache::ALL);
sfContext::switchTo('backend'); //switch back to the environment you started from
like image 79
Jeremy Kauffman Avatar answered Sep 30 '22 08:09

Jeremy Kauffman