Let your web app fly-use the. NET Cache Mechanism

Source: Internet
Author: User
A major limitation of Web application systems is the customer's speed. Therefore, the speed of communication over the Internet is limited. Therefore, it is essential for developers to speed up Internet application systems.
Today, we will only talk about how to improve web apps from the perspective of using the cache mechanism on the server side, so it will not include the page Cache Technology on the client side.
First, let's analyze what affects the performance of Web applications. First, the Web is sent from the client (defined as Phase A), then the data is read from the database (Phase B), and then the page is generated based on the page cycle (Phase C ), finally, send the page to the remote client (Phase D) to complete a web application. The most time spent on Database Operations (Phase B) based on online data is often the most-and more than 90% of the total time (I think it is exaggerated, but after all, it is an I/O operation ).
To improve the system's performance in Phase B, there are commonly used strategies such as asynchronous operations (not discussed) and cache mechanisms. Let the system keep the results of the first database query in the memory, so that later visitors can directly obtain results from memory instead of accessing the database. Please note! But now the problem arises again. client requests are diverse. How does the system map requests to the cache? Although the customer's requests are diverse, our concerns are simple. Customer data modification, data insertion, and data deletion do not need to be cached. All we need to consider is the query (select) operation. Then we only need to create a key-value pair between the query condition and the cache.
I think there is only one last problem. When another customer modifies the data, will the system still read the data in the cache? Of course not! After the data is modified, you must notify the cache to clear or update the cache.
All the attention sounds good, but it seems complicated. In fact, all these implementations are not complicated.
Sql2005 and. Net have prepared everything for us. You can run the aspnet_regsql.exe command to automatically create a stored procedure in SQL Server. With these settings, the system will automatically notify. net when we modify the database, and. NET will automatically clear the related cache. Note that the cache is related, that is, not only the cache of changed data will be cleared, but also the data associated with it will be cleared to ensure data consistency. How does the system know the correlation of data?
This is defined in Web. config.
. NET provides several classes for us to automatically complete all cache operations.
Sqlcachedependency
Admincachingdependency
Cache
You can use msdn to query. I do not provide a demonstration similar to "helloworld ()" here. Code . If you need code, mail me the davyjiang@live.cn.

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.