/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { if (!class_exists('DbFinder')) { throw new Exception('sfCombine expects DbFinder to call combined asset file'); } // initialize database manager $databaseManager = new sfDatabaseManager($this->configuration); $flag = true; if (function_exists('apc_store') && ini_get('apc.enabled')) { $cache = new sfAPCCache(); if (!ini_get('apc.enable_cli')) { $this->logSection('combine', 'Check apc.enabled_cli in your ini file', null, 'ERROR'); $flag = false; } } else { $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir') . '/combiners')); } if ($flag) { $results = DbFinder::from('sfCombine')->find(); foreach ($results as $result) { $cache->remove($result->getAssetsKey()); } $this->logSection('combine', 'Cleanup cache complete', null, 'INFO'); $nbAssets = DbFinder::from('sfCombine')->delete(); $this->logSection('combine', sprintf('Cleanup database complete (%d rows deleted)', $nbAssets), null, 'INFO'); } }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { // initialize database manager $databaseManager = new sfDatabaseManager($this->configuration); $flag = true; if (function_exists('apc_store') && ini_get('apc.enabled')) { $cache = new sfAPCCache(); if (!ini_get('apc.enable_cli')) { $this->logSection('combine', 'Check apc.enable_cli in your ini file', null, 'ERROR'); $flag = false; } } else { $cache = new sfFileCache(array('cache_dir' => sfCombineUtility::getCacheDir())); } if ($flag) { if (!class_exists('sfCombine')) { $this->logSection('combine', 'Call the task `doctrine:build-model`', null, 'ERROR'); return false; } $results = Doctrine::getTable('sfCombine')->findAll(); foreach ($results as $result) { $cache->remove($result->getAssetKey()); } $this->logSection('combine', 'Cleanup cache complete', null, 'INFO'); $deleted = Doctrine::getTable('sfCombine')->deleteAll(); $this->logSection('combine', sprintf('Cleanup database complete (%d rows deleted)', $deleted), null, 'INFO'); } }
/** * Writes a cache file. * * @param string An absolute filesystem path to a configuration file * @param string An absolute filesystem path to the cache file that will be written * @param string Data to be written to the cache file * * @throws sfCacheException If the cache file cannot be written */ protected function writeCacheFile($config, $cache, &$data) { $fileCache = new sfFileCache(dirname($cache)); $fileCache->initialize(array('lifeTime' => 86400 * 365 * 10, 'automaticCleaningFactor' => 0)); $fileCache->setWriteControl(true); $fileCache->setSuffix(''); if (!$fileCache->set(basename($cache), '', $data)) { $fileCache->remove(basename($cache), ''); throw new sfConfigurationException(sprintf('Unable to write config cache for "%s".', $config)); } }
/** * Removes a cache file. * * @param string The cache id * @param string The name of the cache namespace * * @return boolean true if no problem */ public function remove($id, $namespace = self::DEFAULT_NAMESPACE) { list($path, $file) = $this->getFileName($id, $namespace); try { if (!self::$mem[$this->bucket]->delete($path . $file)) { throw new Exception('Unable to remove from memcache'); } } catch (Exception $e) { parent::remove($id, $namespace); } }