You are here

public function DrupalMemcached::addServer in Zircon Profile 8.0

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

Adds a memcache server.

Parameters

string $server_path: The server path including port.

bool $persistent: Whether this server connection is persistent or not.

Overrides DrupalMemcacheInterface::addServer

File

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

Class

DrupalMemcached
Class DrupalMemcached.

Namespace

Drupal\memcache

Code

public function addServer($server_path, $persistent = FALSE) {
  list($host, $port) = explode(':', $server_path);
  if ($host == 'unix') {

    // Memcached expects just the path to the socket without the protocol
    $host = substr($host, 7);

    // Port is always 0 for unix sockets.
    $port = 0;
  }
  return $this->memcache
    ->addServer($host, $port, $persistent);
}