<?php
function memcache_con($key){
$hosts=array(
'192.168.118.120',
'192.168.118.121',
'192.168.118.122',
);
// 16进制转10 取余 ,根据缓存服务器数量 count
$index=hexdec(substr(md5($key),0,5)%3);
$host=$index[$index];
return memcache_connect($host,11711);
}
//操作的时候
$mem=memcache_con($key);
php memcache多台服务器负载均衡简单实现-取余
最新推荐文章于 2020-07-13 17:36:24 发布