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