downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Memcached::append> <Memcached::addServer
[edit] Last updated: Fri, 25 May 2012

view this page in

Memcached::addServers

(PECL memcached >= 0.1.1)

Memcached::addServers複数のサーバーをサーバープールに追加する

説明

public bool Memcached::addServers ( array $servers )

Memcached::addServers() は、 servers をサーバープールに追加します。 servers の各エントリは、 個々のサーバーのホスト名、ポート、重み (オプション) を含む配列となります。 この時点では、サーバーへの接続は確立されません。

同じサーバーがサーバープール内で複数回あらわれることもあります。 重複チェックはしていないからです。これは望ましい状態ではありません。 その代わりに weight オプションを使用して、 このサーバーを選択する重みを増やします。

パラメータ

array

プールに追加するサーバーの配列。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例1 Memcached::addServers() の例

<?php
$m 
= new Memcached();

$servers = array(
    array(
'mem1.domain.com'1121133),
    array(
'mem2.domain.com'1121167)
);
$m->addServers($servers);
?>

参考



add a note add a note User Contributed Notes Memcached::addServers
Michael Brenden 16-Feb-2011 08:27
See the note for __construct()

Important to not call ->addServers() every run -- only call it if no servers exist (check getServerList() ); otherwise, since addServers() does not check for dups, it will let you add the same server again and again and again, resultings in hundreds if not thousands of connections to the MC daemon.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites