Development

#3072 (The cache:clear task should be able to clear the template cache for non file cache factories)

You must first sign up to be able to contribute.

Ticket #3072 (closed defect: fixed)

Opened 9 months ago

Last modified 9 months ago

The cache:clear task should be able to clear the template cache for non file cache factories

Reported by: francois Assigned to: fabien
Priority: major Milestone: 1.1.0
Component: cache Version: 1.1.0 DEV
Keywords: Cc:
Qualification: Unreviewed

Description

As of now, the cache:clear task only empties the cache/ dir.

But since it accepts an "application" parameter, it should be possible to get the view cache manager (as well as the new general cache manager) from the context and clean the related cache engines.

That way, with no need for any event registration, the cache would be cleared with a "symfony cc frontend" even with SQLite cache or Memcached.

Change History

03/09/08 22:05:48 changed by fabien

  • status changed from new to assigned.
  • milestone set to 1.1.0.

The view cache manager and all local caches (there is no general cache manager) are from the factories.yml file which is initialized by sfContext. And as of now, I've tried to avoid the sfContext initialization.

But then, it would be nice if the cc task take all the caches into account. So, I think we can try to just load the factories.yml file.

03/10/08 21:54:49 changed by dwhittle

In theory this works, but you have to initialize the context (and create config cache) in order to delete it.

For each app/environment:

$config  = sfApplicationConfiguration::getForApplication($arguments['application'], $arguments['environment'], true, getcwd());

$context = sfContext::createInstance($config, $arguments['application']);

$context->getInstance()->getCache()->clean(sfCache::ALL);
$this->logSection('cache', sprintf('cleared internal cache for application "%s" and environment "%s"', $arguments['application'], $arguments['environment']));

$context->getInstance()->getViewCacheManager()->getCache()->clean(sfCache::ALL);
$this->logSection('cache', sprintf('cleared view cache for application "%s" and environment "%s"', $arguments['application'], $arguments['environment']));

Since the task needs to delete cache for all apps and environments (and each app/env can have its own factories). What is the best way to find all cache factories / apps / environments?

Apps are easy to find - all dirs in the apps dir? Environments we should be able to do array key on settings.yml and remove 'all'? To find cache factories, we have to init each app or parse factories.yml?

(sorry for overstating the obvious - just trying to be clear)

03/12/08 02:03:52 changed by fabien

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [7815]) rewrote the cache:clear task (closes #3072)

  • moved application and type argument to options (now you can remove all config cache for all applications)
  • added an env option to be able to remove the cache for only one environment
  • changed the way we find available applications (more robust)
  • caches are now cleaned by the cache objects defined in factories.yml (config, template, i18n, and routing)
  • cache:clear is now able to handle caches stored with any sfCache class
  • added a task.cache.clear event to be able to add new cache type, or override the cache cleaning process of an existing type (see sfSuperCachePlugin for an example)