minor #20902 [Cache] Improve performances into foreach (PhpFilesAdapter) (hadjedjvincent)
This PR was squashed before being merged into the 3.2 branch (closes #20902).
Discussion
----------
[Cache] Improve performances into foreach (PhpFilesAdapter)
| Q | A
| ------------- | ---
| Branch? | 3.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| License | MIT
Let's prevent some useless call to be made into this foreach (ini_get)
Commits
-------
7e4573b
[Cache] Improve performances into foreach (PhpFilesAdapter)
This commit is contained in:
commit
638533b532
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user