1 回答

TA貢獻1798條經驗 獲得超7個贊
map.set
使附近的緩存無效,不要將新值放在那里Near Cache 僅用于基于鍵的訪問,您的循環根本不會命中 Near Cache。您需要像這樣更改循環中的第二行:
String value = nearCacheMap.get(entrySet.getKey());
或將循環更改為 keySet
for (Double key : nearCacheMap.keySet()) { String value = entrySet.getValue(key); }
即使更改后,您仍然會看到 0,因為您只進行了 1 次獲取操作,這是緩存未命中。如果您多次重復循環和統計打印,您將看到:
---------------------------Before Sort----------------------------------
------------------------------------------------Read Both---------------------------------------------------
Near Cache hit/miss ratio = 0 / 100000
Near cache implemented or not 10
EndTime timeDifference : 1548313357643 1548313362527 4884
------------------------------------------------Read Both---------------------------------------------------
Near Cache hit/miss ratio = 10 / 199990
Near cache implemented or not 10
EndTime timeDifference : 1548313357643 1548313367155 9512
------------------------------------------------Read Both---------------------------------------------------
Near Cache hit/miss ratio = 20 / 299980
Near cache implemented or not 10
EndTime timeDifference : 1548313357643 1548313371688 14045
添加回答
舉報