[Cache] Improve performances into foreach (PhpFilesAdapter)

This commit is contained in:
Vincent HADJEDJ 2016-12-13 15:25:53 +01:00 committed by Nicolas Grekas
parent c41cfcb897
commit 7e4573bcfb

View File

@ -92,6 +92,7 @@ class PhpFilesAdapter extends AbstractAdapter
{
$ok = true;
$data = array($lifetime ? time() + $lifetime : PHP_INT_MAX, '');
$allowCompile = 'cli' !== PHP_SAPI || ini_get('opcache.enable_cli');
foreach ($values as $key => $value) {
if (null === $value || is_object($value)) {
@ -116,7 +117,7 @@ class PhpFilesAdapter extends AbstractAdapter
$file = $this->getFile($key, true);
$ok = $this->write($file, '<?php return '.var_export($data, true).';') && $ok;
if ('cli' !== PHP_SAPI || ini_get('opcache.enable_cli')) {
if ($allowCompile) {
@opcache_compile_file($file);
}
}