Instantiates a cache backend class for a given cache bin.
By default, this returns an instance of the Drupal\Core\Cache\DatabaseBackend class.
Classes implementing Drupal\Core\Cache\CacheBackendInterface can register themselves both as a default implementation and for specific bins.
string $bin: The cache bin for which a cache backend object should be returned.
\Drupal\Core\Cache\CacheBackendInterface The cache backend object associated with the specified bin.
public function get($bin) {
$cache_settings = $this->settings
->get('cache');
if (isset($cache_settings[$bin])) {
$service_name = $cache_settings[$bin];
}
elseif (isset($cache_settings['default'])) {
$service_name = $cache_settings['default'];
}
else {
$service_name = 'cache.backend.database';
}
return $this->container
->get($service_name)
->get($bin);
}