コード例 #1
0
 /**
  * @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.enabled_cli in your ini file', null, 'ERROR');
             $flag = false;
         }
     } else {
         $cache = new sfFileCache(array('cache_dir' => sfCombinePlusUtility::getCacheDir()));
     }
     if ($flag) {
         $results = sfCombinePlus::getAll();
         foreach ($results as $result) {
             $cache->remove($result->getAssetKey());
         }
         $this->logSection('combine', 'Cleanup cache complete', null, 'INFO');
         $deleted = sfCombinePlus::deleteAll();
         $this->logSection('combine', sprintf('Cleanup database complete (%d rows deleted)', $deleted), null, 'INFO');
     }
 }
コード例 #2
0
 /**
  * @see sfCombinePlusUtility::getCacheDir()
  */
 public static function getCacheDir()
 {
     return sfCombinePlusUtility::getCacheDir();
 }
コード例 #3
0
 /**
  * Return a hash which refers to an entry in the db describing the files
  *
  * Based off the sfCombine _getKey method
  *
  * @see getFileString
  */
 public static function getKey(array $files, $separator = ' ')
 {
     $content = self::getBase64($files, $separator);
     $key = sha1($content);
     $check = false;
     if (function_exists('apc_store') && ini_get('apc.enabled')) {
         $cache = new sfAPCCache();
         $check = $cache->has($key);
     } else {
         $cache = new sfFileCache(array('cache_dir' => sfCombinePlusUtility::getCacheDir()));
         $check = $cache->has($key);
     }
     // Checks if key exists
     if (false === $check) {
         // now just doctrine
         $keyExists = sfCombinePlus::hasKey($key);
         if (!$keyExists) {
             $combine = new sfCombinePlus();
             $combine->setAssetKey($key);
             $combine->setFiles($content);
             $combine->save();
         }
         $cache->set($key, $content);
     }
     return $key;
 }