Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0a85ad

Browse files
[Cache] fix warming up cache.system and apcu
1 parent 424773d commit b0a85ad

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/Symfony/Component/Cache/Adapter/AbstractAdapter.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) {
9494
}
9595

9696
/**
97-
* Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
97+
* Returns the best possible adapter that your runtime supports.
9898
*
9999
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
100100
*
@@ -108,16 +108,12 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) {
108108
*/
109109
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
110110
{
111-
if (null === self::$apcuSupported) {
112-
self::$apcuSupported = ApcuAdapter::isSupported();
111+
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
112+
if (null !== $logger) {
113+
$opcache->setLogger($logger);
113114
}
114115

115-
if (!self::$apcuSupported) {
116-
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
117-
if (null !== $logger) {
118-
$opcache->setLogger($logger);
119-
}
120-
116+
if (!self::$apcuSupported = self::$apcuSupported ?? ApcuAdapter::isSupported()) {
121117
return $opcache;
122118
}
123119

@@ -128,7 +124,7 @@ public static function createSystemCache($namespace, $defaultLifetime, $version,
128124
$apcu->setLogger($logger);
129125
}
130126

131-
return $apcu;
127+
return new ChainAdapter([$apcu, $opcache]);
132128
}
133129

134130
public static function createConnection($dsn, array $options = [])

0 commit comments

Comments
 (0)