You are here

public function DrupalMemcachedFactory::__construct in Memcache Storage 8

Constructs the factory object.

Parameters

\Drupal\Core\Site\Settings $settings: An object with site settings.

Throws

\Drupal\memcache_storage\DrupalMemcachedInitializeException

File

src/DrupalMemcachedFactory.php, line 48

Class

DrupalMemcachedFactory

Namespace

Drupal\memcache_storage

Code

public function __construct(Settings $settings) {

  // Validate pecl extension configuration.
  $this->extension = DrupalMemcachedUtils::getPeclExtension();
  if (!class_exists($this->extension) || !in_array($this->extension, [
    'Memcache',
    'Memcached',
  ])) {
    throw new DrupalMemcachedInitializeException('Could not initialize ' . $this->extension . ' PECL extension');
  }

  // Keep memcache_storage settings.
  $this->settings = $settings
    ->get('memcache_storage', []);

  // Get configuration of cache bins per memcached clusters.
  if (!empty($this->settings['bins_clusters'])) {
    $this->bins_clusters = $this->settings['bins_clusters'];
  }
}