Esempio n. 1
0
        public static BaseUserEntity GetObjectByCompanyIdByCodeByCache(string companyId, string userCode)
        {
            BaseUserEntity result = null;

            // 检查参数有效性
            if (string.IsNullOrWhiteSpace(companyId) || string.IsNullOrWhiteSpace(userCode))
            {
                return(result);
            }

            string key = "User:ByCompanyId:ByCode" + companyId + ":" + 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.GetObjectByCompanyIdByCode(companyId, userCode);

                SetCache(result);
            }

            return(result);
        }