鍍金池/ 問答/PHP  網(wǎng)絡安全/ memcache采用求模算法實現(xiàn)的分布式緩存為什么數(shù)據(jù)均勻性不高?

memcache采用求模算法實現(xiàn)的分布式緩存為什么數(shù)據(jù)均勻性不高?

網(wǎng)上說求模算法實現(xiàn)的數(shù)據(jù)分散性好,但是我自己在本地使用windows+php+memcache測試卻不是這樣。通過memadmin可視化工具查看memcache緩存,發(fā)現(xiàn)3臺memcache服務器緩存的數(shù)量相差較大,分別是15、29、55條數(shù)據(jù),為什么會是這樣呢?

<?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);
    }
回答
編輯回答
挽青絲

數(shù)據(jù)量太少,沒有參考價值,在有大量數(shù)據(jù)的情況下,求模算法實現(xiàn)的數(shù)據(jù)分布是比較均勻的

2017年5月16日 13:22