Last active
July 22, 2018 13:38
-
-
Save jwage/000b294ac00799ea684d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Component\HttpKernel\CacheWarmer; | |
use Spork\Batch\Strategy\ChunkStrategy; | |
use Spork\ProcessManager; | |
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate; | |
class SporkCacheWarmerAggregate extends CacheWarmerAggregate | |
{ | |
protected $chunks = 10; | |
/** | |
* Warms up the cache. | |
* | |
* @param string $cacheDir The cache directory | |
*/ | |
public function warmUp($cacheDir) | |
{ | |
$spork = new ProcessManager(); | |
$warmers = array(); | |
foreach ($this->warmers as $warmer) { | |
if (!$this->optionalsEnabled && $warmer->isOptional()) { | |
continue; | |
} | |
$warmers[] = $warmer; | |
} | |
$batch = $spork->createBatchJob( | |
$warmers, | |
new ChunkStrategy($this->chunks) | |
); | |
$batch->execute(function ($warmer) use ($cacheDir) { | |
$warmer->warmUp($cacheDir); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment