public string CreateTokenAuthentication(int userId) { try { string CacheName = ProjectConst.TokenCacheName + userId; var TokenKey = Guid.NewGuid().ToString(); long ExpireDate = DateTime.Now.AddMinutes(ConfigManager.GetData(ProjectConst.TokenExpireTime).ToDouble()).ToLong(); var Entity = new TokenAuthenticationEntity { UserId = userId, ExpireDate = ExpireDate, TokenKey = TokenKey }; if (_redisManager.IsExsistByName <TokenAuthenticationEntity>(CacheName)) { _redisManager.RemoveSingleByName <TokenAuthenticationEntity>(CacheName); } _redisManager.AddSingle(CacheName, Entity, DateTime.Now.AddMinutes(ConfigManager.GetData(ProjectConst.TokenCacheTime).ToDouble())); return(TokenKey); } catch (KnownException ex) { throw ex; } catch (Exception ex) { _logger.AddLog("", LogTypeEnum.Error, "AuthenticationManager.CreateTokenAuthentication", userId, ex.Message, "", ex); throw new KnownException(ErrorTypeEnum.GeneralExeption, ex.Message, ex); } }