1
Vote

MRU Cache Issues

description

Partly already reported in the forums here: http://iqtoolkit.codeplex.com/discussions/262302
 
MRU cache will not actually move queries to the front of the list. If you were to fix this fact, it would be inserting the 'uncompiled' form of the query, instead of the compiled form. In addition to this, the MRU cache performs a search over every cached query, even if a match is found (for example as the first item).
 
From MostRecentlyUsedCache, following loop is found 2 places in Lookup() function
 
for (int i = 0, n = this.list.Count; i < n; i++)
{
cached = this.list[i];
if (fnEquals(cached, item))
{
    cacheIndex = 0; // should be cacheIndex = i
    // should break here since we already have a match
}
}
 
later MRU cache attempts to move the item to the front of the list
 
else
{
if (cacheIndex > 0)
{
    // if item is not at start, move it to the start
    this.list.RemoveAt(cacheIndex); // we updated cacheIndex properly above so it will move to proper spot now
    this.list.Insert(0, item); // should be this.list.Insert(0, cached) to re-insert the compiled query, instead of the uncompiled query stored in item
}
}

comments