網(wǎng)上說(shuō)求模算法實(shí)現(xiàn)的數(shù)據(jù)分散性好,但是我自己在本地使用windows+php+memcache測(cè)試卻不是這樣。通過(guò)memadmin可視化工具查看memcache緩存,發(fā)現(xiàn)3臺(tái)memcache服務(wù)器緩存的數(shù)量相差較大,分別是15、29、55條數(shù)據(jù),為什么會(huì)是這樣呢?
<?php
$memcache = new Memcache();
$host = '127.0.0.1';
$port1 = 11212;
$port2 = 11213;
$port3 = 11214;
$memcache->addServer($host, $port1);
$memcache->addServer($host, $port2);
$memcache->addServer($host, $port3);
$key = 'key';
$value = 'value';
for ($i = 1; $i < 100; $i++) {
$status = $memcache->set($key . $i, $value . $i);
}
memcache采用求模算法實(shí)現(xiàn)的分布式緩存為什么數(shù)據(jù)均勻性不高?
胡說(shuō)叔叔
2019-03-14 04:49:19