コード例 #1
0
        /// <summary>
        /// 清除页面缓存
        /// </summary>
        /// <param name="cachedFileNames">需要清除的文件名称</param>
        public static void FlushCache(params string[] cachedFileNames)
        {
            var cacheManageUrl = ConfigHelper.As_GetValue("cacheManageUrl");

            if (string.IsNullOrWhiteSpace(cacheManageUrl))
            {
                throw new ConfigurationErrorsException("缓存管理地址配置未能正确读取。");
            }

            if (cachedFileNames == null || cachedFileNames.Length == 0)
            {
                return;
            }

            var postData = string.Concat("action=flushcache&page=", string.Join("||", cachedFileNames));

            ThreadPool.QueueUserWorkItem(state => {
                var httpHelper = new HttpHelper();
                var httpItem   = new HttpItem {
                    URL          = cacheManageUrl,
                    Method       = "POST",
                    ContentType  = "application/x-www-form-urlencoded",
                    PostDataType = PostDataType.String,
                    Postdata     = postData,
                    ResultType   = ResultType.String
                };

                httpHelper.GetHtml(httpItem);
            });
        }
コード例 #2
0
        /// <summary>
        /// 默认构造器
        /// </summary>
        public CachedFileProvider()
        {
            var cachedPagePath = ConfigHelper.As_GetValue("cachedPagePath");

            if (string.IsNullOrWhiteSpace(cachedPagePath))
            {
                throw new ConfigurationErrorsException("缓存文件路径未正确配置。");
            }

            this.CachedPagePath = cachedPagePath;
        }
コード例 #3
0
        /// <summary>
        /// 默认构造器
        /// </summary>
        public CacheEnabledPage()
        {
            var cacheEnabled = ConfigHelper.As_GetValue("cacheEnabled");

            if (string.IsNullOrWhiteSpace(cacheEnabled))
            {
                throw new ConfigurationErrorsException("是否启用缓存策略未能正确配置。");
            }

            this._cachedFileProvider = new CachedFileProvider();

            // 初始化设置
            this.CacheEnabled        = cacheEnabled;
            this.CachedExpiryMinutes = 1440;
            this.CanCache            = false;
            this.ParamsFilter        = new List <string>();
        }