class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface (View source)

Traits

ContainerAwareTrait

Properties

protected Settings $settings

The site settings.

protected array $defaultBinBackends

A map of cache bin to default cache backend service name.

Methods

__construct(Settings $settings, array $default_bin_backends = [])

Constructs CacheFactory object.

get(string $bin)

Instantiates a cache backend class for a given cache bin.

Details

__construct(Settings $settings, array $default_bin_backends = [])

Constructs CacheFactory object.

Parameters

Settings $settings

The site settings.

array $default_bin_backends

(optional) A mapping of bin to backend service name. Mappings in $settings take precedence over this.

CacheBackendInterface get(string $bin)

Instantiates a cache backend class for a given cache bin.

By default, this returns an instance of the Drupal\Core\Cache\DatabaseBackend class.

Classes implementing Drupal\Core\Cache\CacheBackendInterface can register themselves both as a default implementation and for specific bins.

Parameters

string $bin

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

Return Value

CacheBackendInterface

The cache backend object associated with the specified bin.