Always rotate tables if new table exceeds threshold.
This commit is contained in:
parent
dba715b2db
commit
6266b3b5b7
1 changed files with 9 additions and 8 deletions
|
@ -231,14 +231,15 @@ public class CacheMap {
|
||||||
oldValue = oldTable.get (key);
|
oldValue = oldTable.get (key);
|
||||||
if (oldValue != null)
|
if (oldValue != null)
|
||||||
oldTable.remove( key );
|
oldTable.remove( key );
|
||||||
else {
|
// we put a key into newtable that wasn't there before. check if it
|
||||||
if (newTable.size() >= threshold) {
|
// grew beyond the threshold
|
||||||
// Rotate the tables.
|
if (newTable.size() >= threshold) {
|
||||||
if (logger != null)
|
// Rotate the tables.
|
||||||
logger.log ("Rotating Cache tables at "+newTable.size()+"/"+oldTable.size()+" (new/old)");
|
if (logger != null)
|
||||||
oldTable = newTable;
|
logger.log ("Rotating Cache tables at "+newTable.size()+
|
||||||
newTable = new HashMap (eachCapacity, loadFactor);
|
"/"+oldTable.size()+" (new/old)");
|
||||||
}
|
oldTable = newTable;
|
||||||
|
newTable = new HashMap (eachCapacity, loadFactor);
|
||||||
}
|
}
|
||||||
return oldValue;
|
return oldValue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue