Analysis on the application of caching mechanism in asp.net forums

Source: Internet
Author: User
Tags datetime empty
Asp.net| Cache Analysis of the application of caching mechanism in asp.net forums

There are three kinds of caching mechanisms in asp.net, and I'm mainly talking about caching API cache objects used in asp.net forums
The cache object can be said to be ubiquitous in asp.net forums to
Siteurls () class as an example
The following code is available in the constructor
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];
Reversepaths = (NameValueCollection) httpruntime.cache[cachekeyreverse];

This class is used to store the hyperlink collection, he will first determine whether the key value is empty, if it is empty, the contents of the Web\siteurls.config
Loading into the cache, if it already exists, read directly from the cache and read the content in memory, which is much faster than reading on the hard disk.
By System.Web.Caching.CacheDependency the contents and files in the cache, if the source file changes, it will be more
The new cache.

In addition AspNetForums.Components.Globals (). Loadskinnedtemplate is also a very typical application of cache objects.
He will determine if the server control is already in the cache, and not recreate it if it exists.

Reasonable use of cache can make the speed of the program greatly improved, because the knot saves a lot of unnecessary read or create time.

I was wondering if the system overhead would be cost-effective if the synchronization of asynchronous threads were to be made before the cache was judged. But if the asynchronous thread
After synchronization, you should be able to improve the system's concurrent load capacity, for this has no experimental experience, hope that experienced friends can be pointing!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.