Пример #1
0
        /// <summary>
        /// 获取当前请求的缓存策略
        /// </summary>
        /// <param name="context">当前请求的 MVC 上下文</param>
        /// <param name="action">请求的 Action</param>
        /// <param name="parameters">Action 的参数信息</param>
        /// <returns></returns>
        public static CachePolicy CreateCachePolicy(ControllerContext context, ActionDescriptor action, IDictionary <string, object> parameters)
        {
            lock ( _cachePolicyProvidersSync )
            {
                foreach (var provider in CachePolicyProviders)
                {
                    var policy = provider.CreateCachePolicy(context, action, parameters);
                    if (policy != null)
                    {
                        return(policy);
                    }
                }

                return(DefaultCachePolicyProvider.CreateCachePolicy(context, action, parameters));
            }
        }
Пример #2
0
 static DefaultCachePolicyProvider()
 {
     CacheKeyPolicy = CacheKeyPolicy.NoCache;
     CacheDuration  = new TimeSpan(0);
     Instance       = new DefaultCachePolicyProvider();
 }