class CacheFactoryDecorator

Same name in other branches
  1. 10 core/modules/system/tests/modules/performance_test/src/Cache/CacheFactoryDecorator.php \Drupal\performance_test\Cache\CacheFactoryDecorator

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

Hierarchy

Expanded class hierarchy of CacheFactoryDecorator

1 string reference to 'CacheFactoryDecorator'
performance_test.services.yml in core/modules/system/tests/modules/performance_test/performance_test.services.yml
core/modules/system/tests/modules/performance_test/performance_test.services.yml
1 service uses CacheFactoryDecorator
performance_test.cache_factory in core/modules/system/tests/modules/performance_test/performance_test.services.yml
Drupal\performance_test\Cache\CacheFactoryDecorator

File

core/modules/system/tests/modules/performance_test/src/Cache/CacheFactoryDecorator.php, line 16

Namespace

Drupal\performance_test\Cache
View source
class CacheFactoryDecorator implements CacheFactoryInterface {
    
    /**
     * All wrapped cache backends.
     *
     * @var \Drupal\performance_data\Cache\CacheBackendDecorator[]
     */
    protected array $cacheBackends = [];
    public function __construct(CacheFactoryInterface $cacheFactory, PerformanceDataCollector $performanceDataCollector) {
    }
    
    /**
     * {@inheritdoc}
     */
    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];
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
CacheFactoryDecorator::$cacheBackends protected property All wrapped cache backends.
CacheFactoryDecorator::get public function Gets a cache backend class for a given cache bin. Overrides CacheFactoryInterface::get
CacheFactoryDecorator::__construct public function

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