/** * Sets the infos * * @param array $infos Infos * * @return void */ public static function set_infos($infos) { self::$infos = $infos; }
/** * Processes the cache primer. * * @return void * * @author Patrick Schneider <*****@*****.**> * @since 07.02.2013 */ public function process() { parent::process(); $primeIndex = $this->getPrimeIndex(); $threads = $this->getThreads(); $locales = $this->getLocales(); if (count($locales) > 1) { foreach ($locales as $locale) { // start locale thread chdir(Director::baseFolder()); $command = sprintf('sake SilvercartCachePrimer url="%s" threads=%s locale=%s', $this->getUrlToPrimeCacheFor(), $threads, $locale); $PID = self::run_process_in_background($command); $this->printInfo('Started thread for locale ' . $locale . ' with PID ' . $PID . '.'); } } elseif (is_null($primeIndex)) { $this->buildSitemapXmlFiles(); // only one locale, split and call with prime index $this->splitSitemapForThreads(); $countOfUrlsToCall = $this->getCountOfUrlsToCall(); $urlsPerThread = ceil($countOfUrlsToCall / $threads); $currentLocale = $this->getCurrentLocale(); if ($countOfUrlsToCall == 0) { $this->printError('The target URL has no pages to prime cache for.'); $this->printUsage(); exit; } $this->printInfo('There are ' . $countOfUrlsToCall . ' pages to prime cache for locale ' . $currentLocale . '.'); $this->printInfo('Primer will be splitted into ' . $threads . ' threads (threads are running in background).'); $this->printInfo('One thread will handle ' . $urlsPerThread . ' (or less) URLs.'); chdir(Director::baseFolder()); for ($x = 1; $x <= $threads; $x++) { $command = sprintf('sake SilvercartCachePrimer url="%s" locale=%s prime-index=%s', $this->getUrlToPrimeCacheFor(), $currentLocale, $x); $PID = self::run_process_in_background($command); $this->printInfo('Started ' . $currentLocale . ' thread #' . $x . ' with PID ' . $PID . '.'); } exit; } else { $this->LogForThread('Starting thread...'); $this->primeCache(); exit; } }