Analysis on the Application of Cache Mechanism in ASP.NET Forums

xiaoxiao2021-03-06  100

Analysis on the Application of Cache Mechanism in ASP.NET Forums

There are three caching mechanisms in ASP.NET, which is mainly mentioned here that cache objects used in ASP.NET Forums can be said to be in ASP.NET Forums, with siteURLS () class as an example has the following function codes if (HttpRuntime.Cache [cacheKey] == null) {.System.Web.Caching.CacheDependency dep = new System.Web.Caching.CacheDependency (file);. System.Web.Caching.CacheDependency dep2 = new System.Web.Caching.CacheDependency (file); HttpRuntime.Cache.Insert (cacheKey, paths, dep, DateTime.MaxValue, TimeSpan.Zero); HttpRuntime.Cache.Insert (cacheKeyReverse, reversePaths, dep2, DateTime.MaxValue, TimeSpan .Zero);} Paths = (NameValueCollection) httpruntime.cache [cachekey]; ReversePath = (NameValueCollection) httpruntime.cache [cacheKeyReverse];

This class is used to store hyperlink collection. He will first determine if the key value is empty. If it is empty, load the contents in Web / SiteURLs.config into the cache, if it already exists, it is directly from the cache. Go to read, read content in memory, of course, more than reading on the hard disk, link the contents and files in the cache via system.Web.caching.cachedependence, if the source file is changed, Will update the cache.

Also aspnetforums.components.globals (). LoadskinnedTemplate is also a typical application of a Cache object. It is a more typical app that he will determine if the server control has existed in the cache. If there is, it is not recreated.

Reasonable use of Cache enhances the speed of the program, because there is a lot of unnecessary reading or creation time.

I am thinking, if you add the synchronization of asynchronous threads before doing cache, this system overhead is cost effective? However, if you synchronize the asynchronous thread, you should improve your system's concurrency carrying capacity. For this experience, you can give you an experienced friend!

转载请注明原文地址:https://www.9cbs.com/read-122167.html

New Post(0)