Skip to content
Permalink
Browse files

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
-------

b0a85ad [Cache] fix warming up cache.system and apcu
  • Loading branch information...
nicolas-grekas committed Feb 23, 2019
2 parents 424773d + b0a85ad commit 8ac69b95adaacb7efce74c502fa97a86b9e156b5
Showing with 6 additions and 10 deletions.
  1. +6 −10 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 = [])

0 comments on commit 8ac69b9

Please sign in to comment.
You can’t perform that action at this time.