function ChainedFastBackendFactory::get

Same name in other branches
  1. 9 core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php \Drupal\Core\Cache\ChainedFastBackendFactory::get()
  2. 10 core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php \Drupal\Core\Cache\ChainedFastBackendFactory::get()
  3. 11.x core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php \Drupal\Core\Cache\ChainedFastBackendFactory::get()

Instantiates a chained, fast cache backend class for a given cache bin.

Parameters

string $bin: The cache bin for which a cache backend object should be returned.

Return value

\Drupal\Core\Cache\CacheBackendInterface The cache backend object associated with the specified bin.

Overrides CacheFactoryInterface::get

File

core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php, line 78

Class

ChainedFastBackendFactory
Defines the chained fast cache backend factory.

Namespace

Drupal\Core\Cache

Code

public function get($bin) {
    // Use the chained backend only if there is a fast backend available;
    // otherwise, just return the consistent backend directly.
    if (isset($this->fastServiceName)) {
        return new ChainedFastBackend($this->container
            ->get($this->consistentServiceName)
            ->get($bin), $this->container
            ->get($this->fastServiceName)
            ->get($bin), $bin);
    }
    else {
        return $this->container
            ->get($this->consistentServiceName)
            ->get($bin);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.