Memcached::getServerByKey

(PECL memcached >= 0.1.0)

Memcached::getServerByKey锟斤拷取一锟斤拷key锟斤拷映锟斤拷姆锟斤拷锟斤拷锟斤拷锟较�

说锟斤拷

public Memcached::getServerByKey ( string $server_key ) : array

Memcached::getServerByKey()锟斤拷锟斤拷server_key锟斤拷映锟斤拷姆锟斤拷锟斤拷锟�, Memcached::*ByKey()系锟叫凤拷锟斤拷锟斤拷锟叫碉拷server_key锟斤拷锟斤拷, 实锟斤拷锟较撅拷锟斤拷锟斤拷锟斤拷锟斤拷取 锟斤拷锟斤拷锟侥凤拷锟斤拷锟斤拷锟斤拷.(锟斤拷注: 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�, *ByKey系锟叫猴拷锟斤拷锟斤拷锟饺碉拷锟斤拷Memcached::getServerByKey()锟斤拷取锟斤拷锟斤拷锟斤拷, 然锟斤拷锟节此凤拷锟斤拷锟斤拷锟较斤拷锟叫诧拷锟斤拷.)

锟斤拷锟斤拷

server_key

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷识锟金储达拷投锟饺≈碉拷姆锟斤拷锟斤拷锟斤拷锟矫伙拷薪锟绞碉拷实募锟斤拷锟缴拷械锟斤拷锟斤拷锟斤拷锟斤拷目锟斤拷锟斤拷锟斤拷锟节撅拷锟斤拷锟斤拷锟斤拷一锟斤拷 memcached 锟斤拷锟斤拷锟斤拷通锟斤拷时锟斤拷锟斤拷散锟斤拷为锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷使锟矫癸拷锟斤拷锟斤拷锟斤拷目锟节碉拷一锟侥凤拷锟斤拷锟较憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟竭讹拷锟截诧拷锟斤拷锟斤拷效锟绞★拷

锟斤拷锟斤拷值

锟缴癸拷时锟斤拷锟斤拷 TRUE锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE锟斤拷 锟斤拷锟斤拷要锟斤拷使锟斤拷 Memcached::getResultCode()锟斤拷

锟斤拷锟斤拷

Example #1 Memcached::getServerByKey() 示锟斤拷

<?php
$m 
= new Memcached();
$m->addServers(array(
    array(
'mem1.domain.com'1121140),
    array(
'mem2.domain.com'1121140),
    array(
'mem3.domain.com'1121120),
));

$m->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLEtrue);

var_dump($m->getServerByKey('user'));
var_dump($m->getServerByKey('log'));
var_dump($m->getServerByKey('ip'));
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

array(3) {
  ["host"]=>
  string(15) "mem3.domain.com"
  ["port"]=>
  int(11211)
  ["weight"]=>
  int(20)
}
array(3) {
  ["host"]=>
  string(15) "mem2.domain.com"
  ["port"]=>
  int(11211)
  ["weight"]=>
  int(40)
}
array(3) {
  ["host"]=>
  string(15) "mem2.domain.com"
  ["port"]=>
  int(11211)
  ["weight"]=>
  int(40)
}