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

            string key = "Area:" + id;

            result = BaseAreaManager.GetCache(key);

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

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 刷新列表
        /// 2015-07-17 吉日嘎拉 刷新缓存功能优化
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">父亲节点主键</param>
        /// <returns>数据表</returns>
        public void Refresh(BaseUserInfo userInfo, string id)
        {
            string cacheKey = string.Empty;

            // 把列表的缓存更新掉
            cacheKey = "Area" + id;
            BaseAreaManager.RemoveCache(cacheKey);

            // 重新获取本身的缓存
            // cacheKey = "AreaList" + id;
            BaseAreaManager.GetCache(cacheKey);

            /*
             * System.Web.Caching.Cache cache = HttpRuntime.Cache;
             * string cacheKey = "Area";
             * if (!string.IsNullOrEmpty(parentId))
             * {
             *  cacheKey = "Area" + parentId;
             * }
             * cache.Remove(cacheKey);
             */
        }