You are here

public function MemcachedConnection::addServer in Memcache API and Integration 8.2

Adds a memcache server.

Parameters

string $server_path: The server path including port.

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

Overrides MemcacheConnectionInterface::addServer

File

src/Connection/MemcachedConnection.php, line 51

Class

MemcachedConnection
Class MemcachedConnection.

Namespace

Drupal\memcache\Connection

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($server_path, 7);

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