Skip to content

Commit

Permalink
bug #30331 [Cache] fix warming up cache.system and apcu (nicolas-grekas)
Browse files Browse the repository at this point in the history
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 8ac69b9
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/Symfony/Component/Cache/Adapter/AbstractAdapter.php
Expand Up @@ -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.
*
Expand All @@ -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;
}

Expand All @@ -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 = [])
Expand Down

0 comments on commit 8ac69b9

Please sign in to comment.