You are here

public function DrupalMemcached::__construct in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/memcache/src/DrupalMemcached.php \Drupal\memcache\DrupalMemcached::__construct()

Constructs a DrupalMemcacheBase object.

Parameters

string $bin: The cache bin.

\Drupal\Core\Site\Settings: The settings object.

Overrides DrupalMemcacheBase::__construct

File

modules/memcache/src/DrupalMemcached.php, line 20
Contains \Drupal\memcache\DrupalMemcached.

Class

DrupalMemcached
Class DrupalMemcached.

Namespace

Drupal\memcache

Code

public function __construct($bin, Settings $settings) {
  parent::__construct($bin, $settings);
  $this->memcache = new \Memcached();
  $default_opts = array(
    \Memcached::OPT_COMPRESSION => FALSE,
    \Memcached::OPT_DISTRIBUTION => \Memcached::DISTRIBUTION_CONSISTENT,
  );
  foreach ($default_opts as $key => $value) {
    $this->memcache
      ->setOption($key, $value);
  }

  // See README.txt for setting custom Memcache options when using the
  // memcached PECL extension.
  foreach ($this->settings
    ->get('memcache_options', array()) as $key => $value) {
    $this->memcache
      ->setOption($key, $value);
  }
}