PHP Doku:: Add a server to the server pool - memcached.addserver.html

Verlauf / Chronik / History: (3) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteMemcachedThe Memcached classMemcached::addServer

Ein Service von Reinhard Neidl - Webprogrammierung.

The Memcached class

<<Memcached::addByKey

Memcached::addServers>>

Memcached::addServer

(PECL memcached >= 0.1.0)

Memcached::addServerAdd a server to the server pool

Beschreibung

public bool Memcached::addServer ( string $host , int $port [, int $weight = 0 ] )

Memcached::addServer() adds the specified server to the server pool. No connection is established to the server at this time, but if you are using consistent key distribution option (via Memcached::DISTRIBUTION_CONSISTENT or Memcached::OPT_LIBKETAMA_COMPATIBLE), some of the internal data structures will have to be updated. Thus, if you need to add multiple servers, it is better to use Memcached::addServers() as the update then happens only once.

The same server may appear multiple times in the server pool, because no duplication checks are made. This is not advisable; instead, use the weight option to increase the selection weighting of this server.

Parameter-Liste

host

The hostname of the memcache server. If the hostname is invalid, data-related operations will set Memcached::RES_HOST_LOOKUP_FAILURE result code.

port

The port on which memcache is running. Usually, this is 11211.

weight

The weight of the server relative to the total weight of all the servers in the pool. This controls the probability of the server being selected for operations. This is used only with consistent distribution option and usually corresponds to the amount of memory available to memcache on that server.

Rückgabewerte

Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.

Beispiele

Beispiel #1 Memcached::addServer() example

<?php
$m 
= new Memcached();

/* Add 2 servers, so that the second one
   is twice as likely to be selected. */
$m->addServer('mem1.domain.com'1121133);
$m->addServer('mem2.domain.com'1121167);
?>

Siehe auch


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
Bill Getas
30.08.2010 20:26
Unix sockets are not yet supported by PECL/memcached



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)