Always rotate tables if new table exceeds threshold.

This commit is contained in:
hns 2002-10-30 11:46:51 +00:00
parent dba715b2db
commit 6266b3b5b7

View file

@ -231,15 +231,16 @@ public class CacheMap {
oldValue = oldTable.get (key);
if (oldValue != null)
oldTable.remove( key );
else {
// we put a key into newtable that wasn't there before. check if it
// grew beyond the threshold
if (newTable.size() >= threshold) {
// Rotate the tables.
if (logger != null)
logger.log ("Rotating Cache tables at "+newTable.size()+"/"+oldTable.size()+" (new/old)");
logger.log ("Rotating Cache tables at "+newTable.size()+
"/"+oldTable.size()+" (new/old)");
oldTable = newTable;
newTable = new HashMap (eachCapacity, loadFactor);
}
}
return oldValue;
}