private UserModel GetUserModelForCache(string accessToken)
        {
            string accessTokenKey = EasyCacheKey.Build_AccessToken_Key(accessToken);

            //缓存处理
            var userModel = _easyCache.Get <UserModel>(accessTokenKey);

            return(userModel);
        }
示例#2
0
        private UserModel GetUserModel(string accessToken)
        {
            string accessTokenKey = EasyCacheKey.Build_AccessToken_Key(accessToken);

            //缓存处理
            var userModel = _easyCache.Get(accessTokenKey, () =>
            {
                if (this._authUserService == null)
                {
                    //依赖注入
                    EasyMefContainer.Container.SatisfyImportsOnce(this);
                }

                if (this._authUserService == null)
                {
                    throw new NullReferenceException("未找到MEF导入的IUserService类型");
                }

                return(this._authUserService.GetByToken(accessToken));
            }, TimeSpan.FromDays(7));

            return(userModel);
        }