You are here

public function ChainedFastBackend::__construct in Supercache 2.0.x

Same name and namespace in other branches
  1. 8 src/Cache/ChainedFastBackend.php \Drupal\supercache\Cache\ChainedFastBackend::__construct()

Constructs a ChainedFastBackend object.

Parameters

\Drupal\Core\Cache\CacheBackendInterface $consistent_backend: The consistent cache backend.

\Drupal\Core\Cache\CacheBackendInterface $fast_backend: The fast cache backend.

string $bin: The cache bin for which the object is created.

Throws

\Exception When the consistent cache backend and the fast cache backend are the same service.

File

src/Cache/ChainedFastBackend.php, line 93
Contains \Drupal\supercache\Cache\ChainedFastBackend.

Class

ChainedFastBackend
Defines a backend with a fast and a consistent backend chain.

Namespace

Drupal\supercache\Cache

Code

public function __construct(CacheBackendInterface $consistent_backend, CacheBackendInterface $fast_backend, $bin, $mark_as_outdated_explicit = FALSE) {
  if ($consistent_backend == $fast_backend) {

    // @todo: should throw a proper exception. See https://www.drupal.org/node/2751847.
    trigger_error('Consistent cache backend and fast cache backend cannot use the same service.', E_USER_ERROR);
  }
  $this->consistentBackend = $consistent_backend;
  $this->fastBackend = $fast_backend;
  $this->bin = 'cache_' . $bin;

  // We explicitly execute the outdated call on shutdown.
  $this->doMarkAsOutdatedExplicit = $mark_as_outdated_explicit;
}