Esempio 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);
            }
        }
Esempio n. 2
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 );
      }

    }