コード例 #1
0
        /// <summary>
        /// 从缓存获取获取实体
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public static BaseOrganizeEntity GetObjectByCache(IRedisClient redisClient, string id)
        {
            BaseOrganizeEntity result = null;

            if (!string.IsNullOrEmpty(id))
            {
                //string cacheKey = "Organize";
                string cacheKey = "O:";

                cacheKey = cacheKey + id;
                result   = GetCacheByKey(redisClient, cacheKey);
                if (result == null)
                {
                    BaseOrganizeManager manager = new DotNet.Business.BaseOrganizeManager();
                    result = manager.GetObject(id);
                    // 若是空的不用缓存,继续读取实体
                    if (result != null)
                    {
                        SetCache(result);
                    }
                }
            }

            return(result);
        }
コード例 #2
0
        public static BaseOrganizeEntity GetObjectByCache(string id, bool fefreshCache = false)
        {
            BaseOrganizeEntity result = null;

            if (!string.IsNullOrEmpty(id))
            {
                string cacheKey = "O:";
                cacheKey = cacheKey + id;

                if (!fefreshCache)
                {
                    result = GetCacheByKey(cacheKey);
                }

                if (result == null)
                {
                    BaseOrganizeManager manager = new DotNet.Business.BaseOrganizeManager();
                    result = manager.GetObject(id);
                    // 若是空的不用缓存,继续读取实体
                    if (result != null)
                    {
                        SetCache(result);
                    }
                }
            }

            return(result);
        }