Faster method of moving objects from a temporary cache list to indexed cache lists
This commit is contained in:
@@ -129,18 +129,17 @@ namespace VEPROMS.CSLA.Library
|
||||
private static Dictionary<string, List<Content>> _CacheByPrimaryKey = new Dictionary<string, List<Content>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<Content> remove = new List<Content>();
|
||||
foreach (Content tmp in _CacheList)
|
||||
while (_CacheList.Count > 0) // Move Content(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||
{
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.ContentID.ToString()))
|
||||
Content tmp = _CacheList[0]; // Get the first Content
|
||||
string pKey = tmp.ContentID.ToString();
|
||||
if (!_CacheByPrimaryKey.ContainsKey(pKey))
|
||||
{
|
||||
_CacheByPrimaryKey[tmp.ContentID.ToString()] = new List<Content>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[pKey] = new List<Content>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_CacheByPrimaryKey[tmp.ContentID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
|
||||
_CacheList.RemoveAt(0); // Remove the first Content
|
||||
}
|
||||
foreach (Content tmp in remove)
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
protected static Content GetCachedByPrimaryKey(int contentID)
|
||||
{
|
||||
|
Reference in New Issue
Block a user