function ChainedFastBackendFactory::__construct
Same name in other branches
- 9 core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php \Drupal\Core\Cache\ChainedFastBackendFactory::__construct()
- 8.9.x core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php \Drupal\Core\Cache\ChainedFastBackendFactory::__construct()
- 10 core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php \Drupal\Core\Cache\ChainedFastBackendFactory::__construct()
Constructs ChainedFastBackendFactory object.
Parameters
\Drupal\Core\Site\Settings|null $settings: (optional) The settings object.
string|null $consistent_service_name: (optional) The service name of the consistent backend factory. Defaults to:
- $settings->get('cache')['default'] (if specified)
- 'cache.backend.database' (if the above isn't specified)
string|null $fast_service_name: (optional) The service name of the fast backend factory. Defaults to:
- 'cache.backend.apcu' (if the PHP process has APCu enabled)
- NULL (if the PHP process doesn't have APCu enabled)
File
-
core/
lib/ Drupal/ Core/ Cache/ ChainedFastBackendFactory.php, line 57
Class
- ChainedFastBackendFactory
- Defines the chained fast cache backend factory.
Namespace
Drupal\Core\CacheCode
public function __construct(?Settings $settings = NULL, $consistent_service_name = NULL, $fast_service_name = NULL) {
// Default the consistent backend to the site's default backend.
if (!isset($consistent_service_name)) {
$cache_settings = isset($settings) ? $settings->get('cache') : [];
$consistent_service_name = $cache_settings['default'] ?? 'cache.backend.database';
}
// Default the fast backend to APCu if it's available.
if (!isset($fast_service_name) && function_exists('apcu_fetch')) {
$fast_service_name = 'cache.backend.apcu';
}
$this->consistentServiceName = $consistent_service_name;
// Do not use the fast chained backend during installation. In those cases,
// we expect many cache invalidations and writes, the fast chained cache
// backend performs badly in such a scenario.
if (!InstallerKernel::installationAttempted()) {
$this->fastServiceName = $fast_service_name;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.