bug #28805 Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools" (nicolas-grekas)
This PR was merged into the 4.2-dev branch. Discussion ---------- Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools" This reverts commitd4f5d46b13
, reversing changes made to7e3b7b0b50
. | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Reading #28800, I've just realized that #27549 breaks using system caches with read-only filesystem. Using ApcuAdapter makes system caches compatible with read-only filesystems. Note that this affects only non-warmed up pools, as the warmed-up ones use a faster `PhpArrayAdapter` in front. Commits -------dbc1230735
Revert "feature #27549 [Cache] Unconditionally use PhpFilesAdapter for system pools (nicolas-grekas)"
This commit is contained in:
commit
9a37ba4ab1
@ -1601,6 +1601,7 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
$version = new Parameter('container.build_id');
|
$version = new Parameter('container.build_id');
|
||||||
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
|
$container->getDefinition('cache.adapter.apcu')->replaceArgument(2, $version);
|
||||||
|
$container->getDefinition('cache.adapter.system')->replaceArgument(2, $version);
|
||||||
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);
|
$container->getDefinition('cache.adapter.filesystem')->replaceArgument(2, $config['directory']);
|
||||||
|
|
||||||
if (isset($config['prefix_seed'])) {
|
if (isset($config['prefix_seed'])) {
|
||||||
|
@ -35,16 +35,15 @@
|
|||||||
<tag name="cache.pool" />
|
<tag name="cache.pool" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\PhpFilesAdapter" abstract="true">
|
<service id="cache.adapter.system" class="Symfony\Component\Cache\Adapter\AdapterInterface" abstract="true">
|
||||||
|
<factory class="Symfony\Component\Cache\Adapter\AbstractAdapter" method="createSystemCache" />
|
||||||
<tag name="cache.pool" clearer="cache.system_clearer" />
|
<tag name="cache.pool" clearer="cache.system_clearer" />
|
||||||
<tag name="monolog.logger" channel="cache" />
|
<tag name="monolog.logger" channel="cache" />
|
||||||
<argument /> <!-- namespace -->
|
<argument /> <!-- namespace -->
|
||||||
<argument>0</argument> <!-- default lifetime -->
|
<argument>0</argument> <!-- default lifetime -->
|
||||||
|
<argument /> <!-- version -->
|
||||||
<argument>%kernel.cache_dir%/pools</argument>
|
<argument>%kernel.cache_dir%/pools</argument>
|
||||||
<argument>true</argument>
|
<argument type="service" id="logger" on-invalid="ignore" />
|
||||||
<call method="setLogger">
|
|
||||||
<argument type="service" id="logger" on-invalid="ignore" />
|
|
||||||
</call>
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="cache.adapter.apcu" class="Symfony\Component\Cache\Adapter\ApcuAdapter" abstract="true">
|
<service id="cache.adapter.apcu" class="Symfony\Component\Cache\Adapter\ApcuAdapter" abstract="true">
|
||||||
|
@ -94,6 +94,10 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns an ApcuAdapter if supported, a PhpFilesAdapter otherwise.
|
||||||
|
*
|
||||||
|
* Using ApcuAdapter makes system caches compatible with read-only filesystems.
|
||||||
|
*
|
||||||
* @param string $namespace
|
* @param string $namespace
|
||||||
* @param int $defaultLifetime
|
* @param int $defaultLifetime
|
||||||
* @param string $version
|
* @param string $version
|
||||||
@ -101,23 +105,15 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||||||
* @param LoggerInterface|null $logger
|
* @param LoggerInterface|null $logger
|
||||||
*
|
*
|
||||||
* @return AdapterInterface
|
* @return AdapterInterface
|
||||||
*
|
|
||||||
* @deprecated since Symfony 4.2
|
|
||||||
*/
|
*/
|
||||||
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
|
public static function createSystemCache($namespace, $defaultLifetime, $version, $directory, LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
|
|
||||||
|
|
||||||
if (null === self::$apcuSupported) {
|
if (null === self::$apcuSupported) {
|
||||||
self::$apcuSupported = ApcuAdapter::isSupported();
|
self::$apcuSupported = ApcuAdapter::isSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self::$apcuSupported && null === self::$phpFilesSupported) {
|
if (!self::$apcuSupported) {
|
||||||
self::$phpFilesSupported = PhpFilesAdapter::isSupported();
|
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true);
|
||||||
}
|
|
||||||
|
|
||||||
if (self::$phpFilesSupported) {
|
|
||||||
$opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory);
|
|
||||||
if (null !== $logger) {
|
if (null !== $logger) {
|
||||||
$opcache->setLogger($logger);
|
$opcache->setLogger($logger);
|
||||||
}
|
}
|
||||||
@ -125,14 +121,6 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||||||
return $opcache;
|
return $opcache;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fs = new FilesystemAdapter($namespace, $defaultLifetime, $directory);
|
|
||||||
if (null !== $logger) {
|
|
||||||
$fs->setLogger($logger);
|
|
||||||
}
|
|
||||||
if (!self::$apcuSupported) {
|
|
||||||
return $fs;
|
|
||||||
}
|
|
||||||
|
|
||||||
$apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version);
|
$apcu = new ApcuAdapter($namespace, (int) $defaultLifetime / 5, $version);
|
||||||
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
|
if ('cli' === \PHP_SAPI && !ini_get('apc.enable_cli')) {
|
||||||
$apcu->setLogger(new NullLogger());
|
$apcu->setLogger(new NullLogger());
|
||||||
@ -140,7 +128,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
|
|||||||
$apcu->setLogger($logger);
|
$apcu->setLogger($logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ChainAdapter(array($apcu, $fs));
|
return $apcu;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function createConnection($dsn, array $options = array())
|
public static function createConnection($dsn, array $options = array())
|
||||||
|
@ -12,7 +12,6 @@ CHANGELOG
|
|||||||
* added automatic table creation when using Doctrine DBAL with PDO-based backends
|
* added automatic table creation when using Doctrine DBAL with PDO-based backends
|
||||||
* throw `LogicException` when `CacheItem::tag()` is called on an item coming from a non tag-aware pool
|
* throw `LogicException` when `CacheItem::tag()` is called on an item coming from a non tag-aware pool
|
||||||
* deprecated `CacheItem::getPreviousTags()`, use `CacheItem::getMetadata()` instead
|
* deprecated `CacheItem::getPreviousTags()`, use `CacheItem::getMetadata()` instead
|
||||||
* deprecated the `AbstractAdapter::createSystemCache()` method
|
|
||||||
* deprecated the `AbstractAdapter::unserialize()` and `AbstractCache::unserialize()` methods
|
* deprecated the `AbstractAdapter::unserialize()` and `AbstractCache::unserialize()` methods
|
||||||
* added `CacheCollectorPass` (originally in `FrameworkBundle`)
|
* added `CacheCollectorPass` (originally in `FrameworkBundle`)
|
||||||
* added `CachePoolClearerPass` (originally in `FrameworkBundle`)
|
* added `CachePoolClearerPass` (originally in `FrameworkBundle`)
|
||||||
|
Reference in New Issue
Block a user