From b0a85ad015ced23f66ebd6215176e2cf5161e9ca Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 21 Feb 2019 14:30:53 +0100 Subject: [PATCH] [Cache] fix warming up cache.system and apcu --- .../Component/Cache/Adapter/AbstractAdapter.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index d93ae711bdac..6897fbceee53 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -94,7 +94,7 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) { } /** - * 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. * @@ -108,16 +108,12 @@ function ($deferred, $namespace, &$expiredIds) use ($getId) { */ public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null) { - if (null === self::$apcuSupported) { - self::$apcuSupported = ApcuAdapter::isSupported(); + $opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true); + if (null !== $logger) { + $opcache->setLogger($logger); } - if (!self::$apcuSupported) { - $opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true); - if (null !== $logger) { - $opcache->setLogger($logger); - } - + if (!self::$apcuSupported = self::$apcuSupported ?? ApcuAdapter::isSupported()) { return $opcache; } @@ -128,7 +124,7 @@ public static function createSystemCache($namespace, $defaultLifetime, $version, $apcu->setLogger($logger); } - return $apcu; + return new ChainAdapter([$apcu, $opcache]); } public static function createConnection($dsn, array $options = [])