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.
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', 11211, 33),
array('mem2.domain.com', 11211, 67)
);
$m->addServers($servers);
?>
Michael Brenden
17-Feb-2011 12:27
