Ejemplo n.º 1
0
        /// <summary>
        /// 创建一个标准缓存策略
        /// </summary>
        /// <param name="context">请求上下文</param>
        /// <param name="token">缓存标示</param>
        /// <param name="provider">缓存策略提供程序</param>
        /// <param name="duration">缓存持续时间</param>
        /// <param name="enableClientCache">是否启用客户端缓存</param>
        /// <param name="localcacheVirtualPath">静态文件缓存虚拟路径</param>
        /// <param name="enableMemoryCache">是否启用内存缓存</param>
        public StandardCachePolicy(HttpContextBase context, CacheToken token, ICachePolicyProvider provider, TimeSpan duration, bool enableClientCache, string localcacheVirtualPath, bool enableMemoryCache)
            : base(context, token, provider)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }


            Duration          = duration;
            EnableClientCache = enableClientCache;

            if (localcacheVirtualPath != null)
            {
                var physicalPath = context.Server.MapPath(localcacheVirtualPath);
                CacheStorageProvider = new StaticFileCacheStorageProvider(physicalPath, enableMemoryCache);
            }
            else
            {
                CacheStorageProvider = new WebCacheStorageProvider(HttpRuntime.Cache);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 此方法由 ASP.NET 4 系统调用,不应从用户代码中直接调用。
        /// </summary>
        public static void Initialize()
        {
            ViewEngines.Engines.Add(_viewEngine);

            CachePolicyProviders = new SynchronizedCollection <IMvcCachePolicyProvider>(_cachePolicyProvidersSync);

            GlobalFilters.Filters.Add(GlobalCacheFilter = new GlobalCacheFilter());

            CacheStorageProvider = new WebCacheStorageProvider(HostingEnvironment.Cache);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 此方法由 ASP.NET 4 系统调用,不应从用户代码中直接调用。
        /// </summary>
        public static void Initialize()
        {
            ViewEngines.Engines.Add(_viewEngine);

            CacheStorageProvider = new WebCacheStorageProvider(HostingEnvironment.Cache);
        }