<?php function test($key='name'){ $md5 = substr(md5($key), 0, 8); $seed = 31; $hash = 0; for($i=0; $i'192.168.1.2', 'port'=>6379), array('host'=>'192.168.1.3', 'port'=>6379), array('host'=>'192.168.1.4', 'port'=>6379), array('host'=>'192.168.1.5', 'port'=>6379), ); $key = 'username'; $value = 'lane'; //根据key获取hash $hash = $this->test($key); $count = count($mamcachelist); $mamcache = $mamcachelist[$hash % $count]; $mc = new mamcached($mamcache); $mc->set($key, $value); ?>
