/// <summary> /// Drop the user object in cache by manual. /// </summary> /// <param name="userid"></param> public static void DropUserInCache(int userid) { lock (_userCache) { SolemartUserCacheItem item = _userCache.FirstOrDefault(u => u.SolemartUser.UserID == userid); if (item != null) { _userCache.Remove(item); } } }
/// <summary> /// Get the user object from the cache. /// </summary> /// <param name="userid"></param> /// <returns></returns> public static SolemartUser GetUser(int userid) { SolemartUserCacheItem item = _userCache.FirstOrDefault(u => u.SolemartUser.UserID == userid); if (item == null) { lock (_userCache) { int anonymousUserID = GetAnonymousUserID(); item = new SolemartUserCacheItem { SolemartUser = new SolemartUser(userid, anonymousUserID), AddTime = DateTime.Now }; _userCache.Add(item); } } return(item.SolemartUser); }