bug #30331 [Cache] fix warming up cache.system and apcu (nicolas-grekas)
This PR was merged into the 4.2 branch.
Discussion
----------
[Cache] fix warming up cache.system and apcu
| Q | A
| ------------- | ---
| Branch? | 4.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #29601, #29877
| License | MIT
| Doc PR | -
Commits
-------
b0a85ad015
[Cache] fix warming up cache.system and apcu
This commit is contained in:
commit
8ac69b95ad
@ -94,7 +94,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
|
* Returns the best possible adapter that your runtime supports.
|
||||||
*
|
*
|
||||||
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
|
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
|
||||||
*
|
*
|
||||||
@ -108,16 +108,12 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||||||
*/
|
*/
|
||||||
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
|
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
if (null === self::$apcuSupported) {
|
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
|
||||||
self::$apcuSupported = ApcuAdapter::isSupported();
|
if (null !== $logger) {
|
||||||
|
$opcache->setLogger($logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::$apcuSupported) {
|
if (!self::$apcuSupported = self::$apcuSupported ?? ApcuAdapter::isSupported()) {
|
||||||
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
|
|
||||||
if (null !== $logger) {
|
|
||||||
$opcache->setLogger($logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $opcache;
|
return $opcache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +124,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||||||
$apcu->setLogger($logger);
|
$apcu->setLogger($logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $apcu;
|
return new ChainAdapter([$apcu, $opcache]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createConnection($dsn, array $options = [])
|
public static function createConnection($dsn, array $options = [])
|
||||||
|
Reference in New Issue
Block a user