function CacheFactoryDecorator::get

Same name and namespace in other branches
  1. 10 core/modules/system/tests/modules/performance_test/src/Cache/CacheFactoryDecorator.php \Drupal\performance_test\Cache\CacheFactoryDecorator::get()

Gets a 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/modules/system/tests/modules/performance_test/src/Cache/CacheFactoryDecorator.php, line 30

Class

CacheFactoryDecorator
Decorates a cache factory to register all calls to the cache system.

Namespace

Drupal\performance_test\Cache

Code

public function get($bin) : CacheBackendInterface {
  if (!isset($this->cacheBackends[$bin])) {
    $cache_backend = $this->cacheFactory
      ->get($bin);
    // Don't log memory cache operations.
    if (!$cache_backend instanceof MemoryCacheInterface && !$cache_backend instanceof MemoryBackend) {
      $this->cacheBackends[$bin] = new CacheBackendDecorator($this->performanceDataCollector, $cache_backend, $bin);
    }
    else {
      $this->cacheBackends[$bin] = $cache_backend;
    }
  }
  return $this->cacheBackends[$bin];
}

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