public static BaseUserEntity GetObjectByCodeByCache(string userCode) { BaseUserEntity result = null; string key = "User:ByCode:" + userCode; string id = string.Empty; using (var redisClient = PooledRedisHelper.GetReadOnlyClient()) { id = redisClient.Get <string>(key); if (!string.IsNullOrWhiteSpace(id)) { result = GetObjectByCache(redisClient, id); } } if (result == null) { BaseUserManager manager = new BaseUserManager(); result = manager.GetObjectByCode(userCode); SetCache(result); } return(result); }
/// <summary> /// 按编号获取实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="code">编号</param> /// <returns>实体</returns> public BaseUserEntity GetObjectByCode(BaseUserInfo userInfo, string code) { BaseUserEntity entity = null; var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) => { var manager = new BaseUserManager(dbHelper, userInfo); entity = manager.GetObjectByCode(code); }); return(entity); }