/// <summary> /// 通过token 获取用户信息 /// </summary> /// <param name="token">tokenID</param> /// <returns></returns> public static bool getUserByToken(string token, out UserInfo user) { bool isok = false; user = null; if (!string.IsNullOrEmpty(token) && RedisCommon.getInstance.Exist<UserInfo>(RedisHashEnum.userinfo, token)) { user = RedisCommon.getInstance.Get<UserInfo>(RedisHashEnum.userinfo, token); isok = true; } return isok; }
public static RedisOpearteResult RefreshLoginTokenData(String tokenID, UserInfo val) { RedisOpearteResult result = new RedisOpearteResult { isok = RedisCommon.getInstance.Set<UserInfo>(RedisHashEnum.userinfo, tokenID, val), token = tokenID, result = JsonConvert.SerializeObject(val) }; RedisCommon.getInstance.SetExpire(tokenID, DateTime.Now.AddMinutes(30)); return result; }
public static RedisOpearteResult getToken(UserInfo val) { string tokenID = Guid.NewGuid().ToString(); RedisOpearteResult result = new RedisOpearteResult { isok = RedisCommon.getInstance.Set<UserInfo>(RedisHashEnum.userinfo, tokenID, val), token = tokenID, result = JsonConvert.SerializeObject(val) }; RedisCommon.getInstance.SetExpire(tokenID, DateTime.Now.AddMinutes(30)); return result; }