コード例 #1
0
        public static SiteCDNAccessRule Get(cmSite site, bool useCache = true)
        {
            string            filePath = HostingEnvironment.MapPath(string.Format("~/Views/{0}/.config/SiteCDNAccessRule", site.DistinctName));
            SiteCDNAccessRule cached   = HttpRuntime.Cache[filePath] as SiteCDNAccessRule;

            if (useCache && cached != null)
            {
                return(cached);
            }

            cached = ObjectHelper.BinaryDeserialize <SiteCDNAccessRule>(filePath, new SiteCDNAccessRule());

            HttpRuntime.Cache.Insert(filePath
                                     , cached
                                     , new CacheDependencyEx(new string[] { filePath }, false)
                                     , Cache.NoAbsoluteExpiration
                                     , Cache.NoSlidingExpiration
                                     , CacheItemPriority.NotRemovable
                                     , null
                                     );
            return(cached);
        }