You are here

public function MemcacheConnection::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/MemcacheConnection.php, line 27

Class

MemcacheConnection
Class MemcacheConnection.

Namespace

Drupal\memcache\Connection

Code

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

  // Support unix sockets in the format 'unix:///path/to/socket'.
  if ($host == 'unix') {

    // When using unix sockets with Memcache use the full path for $host.
    $host = $server_path;

    // Port is always 0 for unix sockets.
    $port = 0;
  }

  // When using the PECL memcache extension, we must use ->(p)connect
  // for the first connection.
  return $this
    ->connect($host, $port, $persistent);
}