class CacheBackendFactory in Redis 8
A cache backend factory responsible for the construction of redis cache bins.
Hierarchy
- class \Drupal\redis\Cache\CacheBackendFactory implements CacheFactoryInterface
Expanded class hierarchy of CacheBackendFactory
1 string reference to 'CacheBackendFactory'
1 service uses CacheBackendFactory
File
- src/
Cache/ CacheBackendFactory.php, line 13
Namespace
Drupal\redis\CacheView source
class CacheBackendFactory implements CacheFactoryInterface {
/**
* @var \Drupal\redis\ClientInterface
*/
protected $clientFactory;
/**
* The cache tags checksum provider.
*
* @var \Drupal\Core\Cache\CacheTagsChecksumInterface
*/
protected $checksumProvider;
/**
* The serialization class to use.
*
* @var \Drupal\Component\Serialization\SerializationInterface
*/
protected $serializer;
/**
* List of cache bins.
*
* Renderer and possibly other places fetch backends directly from the
* factory. Avoid that the backend objects have to fetch meta information like
* the last delete all timestamp multiple times.
*
* @var array
*/
protected $bins = [];
/**
* Creates a redis CacheBackendFactory.
*
* @param \Drupal\redis\ClientFactory $client_factory
* @param \Drupal\Core\Cache\CacheTagsChecksumInterface $checksum_provider
* @param \Drupal\redis\Cache\SerializationInterface $serializer
* The serialization class to use.
*/
public function __construct(ClientFactory $client_factory, CacheTagsChecksumInterface $checksum_provider, SerializationInterface $serializer) {
$this->clientFactory = $client_factory;
$this->checksumProvider = $checksum_provider;
$this->serializer = $serializer;
}
/**
* {@inheritdoc}
*/
public function get($bin) {
if (!isset($this->bins[$bin])) {
$class_name = $this->clientFactory
->getClass(ClientFactory::REDIS_IMPL_CACHE);
$this->bins[$bin] = new $class_name($bin, $this->clientFactory
->getClient(), $this->checksumProvider, $this->serializer);
}
return $this->bins[$bin];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheBackendFactory:: |
protected | property | List of cache bins. | |
CacheBackendFactory:: |
protected | property | The cache tags checksum provider. | |
CacheBackendFactory:: |
protected | property | ||
CacheBackendFactory:: |
protected | property | The serialization class to use. | |
CacheBackendFactory:: |
public | function |
Gets a cache backend class for a given cache bin. Overrides CacheFactoryInterface:: |
|
CacheBackendFactory:: |
public | function | Creates a redis CacheBackendFactory. |