2024 年 PHP Conference Japan

Memcached::getServerList

(PECL memcached >= 0.1.0)

Memcached::getServerList取得伺服器池中的伺服器清單

說明

public Memcached::getServerList(): 陣列

Memcached::getServerList() 會傳回其伺服器池中所有伺服器的清單。

參數

這個函式沒有參數。

回傳值

伺服器池中所有伺服器的列表。

範例

範例 #1 Memcached::getServerList() 範例

<?php
$m
= new Memcached();
$m->addServers(array(
array(
'mem1.domain.com', 11211, 20),
array(
'mem2.domain.com', 11311, 80),
));
var_dump($m->getServerList());
?>

以上範例將輸出

array(2) {
  [0]=>
  array(3) {
    ["host"]=>
    string(15) "mem1.domain.com"
    ["port"]=>
    int(11211)
    ["weight"]=>
    int(20)
  }
  [1]=>
  array(3) {
    ["host"]=>
    string(15) "mem2.domain.com"
    ["port"]=>
    int(11311)
    ["weight"]=>
    int(80)
  }
}

新增註釋

使用者貢獻的註釋 1 則註釋

2
rynop
11 年前
此方法在 v2.1.0 版後不再回傳 'weight': https://github.com/php-memcached-dev/php-memcached/pull/56
To Top