php代码
<?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); ?>