protected function execute($arguments = array(), $options = array()) { // initialize the database connection $databaseManager = new sfDatabaseManager($this->configuration); $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection(); $nbAssets = DbFinder::from('sfCombine')->delete(); sfProcessCache::clear(); }
public function clear() { return $this->cache->clean(); } } } $cache = new sfProcessCache(); $t->diag('useCache()'); // Simple queries $cache->clear(); $finder = DbFinder::from('Article'); $finder = $finder->where('Title', 'foo')->limit(1); $key = $finder->getUniqueIdentifier(); $finder->findOne(); $t->is($cache->get($key), null, 'No cache is set until the cache is enabled'); $finder = $finder->where('Title', 'foo')->limit(1)->useCache($cache, 10); $finder->findOne(); $t->isnt($cache->get($key), null, 'useCache() activates query caching on simple find() queries'); $SQL1 = $finder->getLatestQuery(); // SELECT * FROM article WHERE article.title = 'foo' LIMIT 1 $finder->where('Title', 'bar')->findOne(); $SQL2 = $finder->getLatestQuery(); // SELECT * FROM article WHERE article.title = 'bar' LIMIT 1 $t->isnt($SQL1, $SQL2, 'Uncached finder queries trigger SQL queries'); $finder->where('Title', 'foo')->findOne(); $SQL3 = $finder->getLatestQuery(); // Using cache, so no new query: SELECT * FROM article WHERE article.title = 'bar' LIMIT 1
/** * Checks to see if a configuration file has been modified and if so * recompile the cache file associated with it. * * The recompilation only occurs in a non debug environment. * * If the configuration file path is relative, symfony will look in directories * defined in the sfLoader::getConfigPaths() method. * * @param string A filesystem path to a configuration file * * @return string An absolute filesystem path to the cache filename associated with this specified configuration file * * @throws <b>sfConfigurationException</b> If a requested configuration file does not exist * * @see sfLoader::getConfigPaths() */ public function checkConfig($configPath, $optional = false) { static $process_cache_cleared = false; if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { $timer = sfTimerManager::getTimer('Configuration'); } // the cache filename we'll be using $cache = $this->getCacheName($configPath); if (sfConfig::get('sf_in_bootstrap') && is_readable($cache)) { if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { $timer->addTime(); } return $cache; } if (!sfToolkit::isPathAbsolute($configPath)) { $files = sfLoader::getConfigPaths($configPath); } else { $files = is_readable($configPath) ? array($configPath) : array(); } if (!isset($files[0])) { if ($optional) { return null; } // configuration does not exist $error = sprintf('Configuration "%s" does not exist or is unreadable', $configPath); throw new sfConfigurationException($error); } // find the more recent configuration file last modification time $mtime = 0; foreach ($files as $file) { if (filemtime($file) > $mtime) { $mtime = filemtime($file); } } if (!is_readable($cache) || $mtime > filemtime($cache)) { // configuration has changed so we need to reparse it $this->callHandler($configPath, $files, $cache); // clear process cache if ('config/config_handlers.yml' != $configPath && sfConfig::get('sf_use_process_cache') && !$process_cache_cleared) { sfProcessCache::clear(); $process_cache_cleared = true; } } if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { $timer->addTime(); } return $cache; }
public function clear() { sfProcessCache::clear(); }