public static function CacheFactory::get

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

Drupal\Core\Cache\CacheBackendInterface The cache backend object associated with the specified bin.

1 call to CacheFactory::get()
cache in drupal/core/includes/cache.inc
Instantiates and statically caches the correct class for a cache bin.

File

drupal/core/lib/Drupal/Core/Cache/CacheFactory.php, line 30
Contains Drupal\Core\Cache\CacheFactory.

Class

CacheFactory
Defines the cache backend factory.

Namespace

Drupal\Core\Cache

Code

public static function get($bin) {

  // Check whether there is a custom class defined for the requested bin or
  // use the default 'cache' definition otherwise.
  $cache_backends = self::getBackends();
  $class = isset($cache_backends[$bin]) ? $cache_backends[$bin] : $cache_backends['cache'];
  return new $class($bin);
}