Example #1
0
        public static BaseOrganizeEntity GetObjectByNameByCache(BaseUserInfo userInfo, string fullName)
        {
            BaseOrganizeEntity result = null;

            string key = "OBN:" + fullName;
            string id  = string.Empty;

            using (var redisClient = PooledRedisHelper.GetReadOnlyClient())
            {
                id = redisClient.Get <string>(key);
            }
            if (!string.IsNullOrEmpty(id))
            {
                key    = "O:" + id;
                result = BaseOrganizeManager.GetCacheByKey(key);
            }

            // 远程通过接口获取数据
            if (result == null)
            {
                result = GetObjectByName(userInfo, fullName);
            }

            return(result);
        }
Example #2
0
        /// <summary>
        /// 1:默认从只读的缓存服务器获取数据
        /// 2:若读取不到,就会到接口上获取,接口会把数据缓存到只读服务器上,为下次阅读提高性能
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static BaseOrganizeEntity GetObjectByCache(BaseUserInfo userInfo, string id)
        {
            BaseOrganizeEntity result = null;

            string key = "O:" + id;

            result = BaseOrganizeManager.GetCacheByKey(key);

            // 远程通过接口获取数据
            if (result == null)
            {
                result = GetObject(userInfo, id);
            }

            return(result);
        }