. Discussion and comparison of net caching mechanism

Source: Internet
Author: User
Keywords caching implementation can we developers
Tags .net access advantages and disadvantages application cache caching content custom

I believe most developers are more aware of caching, many developers use predefined or custom caching in software development, and get the expected performance boost from the application. This and subsequent articles will detail and discuss the mechanism of caching implementation under the. NET system, and discusses its advantages and disadvantages.

. NET caching mechanism: The actual value of using caching

In Kevinhoffman,lonnykruger's book, developers often need to temporarily store data (temporary data) in a storage medium for quick access. The memory of this temporary data is called caching. If developers use caching appropriately, they can dramatically improve the performance of your application.

The above is a perfect definition of caching, and for now, the rapid and convenient provision of data to core processing code has become an important design requirement. , the rapid is to enhance the user experience, convenient can reduce the system pressure. The cache can accomplish the task, though not so perfect.

. NET caching mechanism in common

Almost all of the various caching mechanisms have the following main commonalities:

1. Provides temporary storage of data, uncertainty about whether the cached data exists.

2. You can set the cache priority.

3. Cache dependencies can be developed, and cached data is not available when dependent on expiration.

4. The core of the cache is the map

. Discussion on the comparison of net caching mechanism

Temporary cache vs Persistent Cache:

In theory, Microsoft. NET cache solution is the most perfect cache implementation, but because of its textbook implementation makes many programmers complain. One possible paradox is that data that has been painstakingly obtained is being crammed into the cache and discarded because of tight system memory, although it is designed to relieve stress. This is not Microsoft's problem, but the insatiable appetite and improper use of programmers.

In many open source caching mechanisms are used in the persistent caching method to achieve, in fact, these are not so much caching, I feel more like an enhanced session, the cache priority, cache dependency mechanism installed on it. It's easy and easy to develop (. NET cache involves a lot of low-level unmanaged code).

Content caching vs Data caching:

Content caching is not the only option, and data caching is not without merit. Although the performance is slightly insufficient, but the data stored in the database but save the cleanup cache Taobao shopping navigation trouble. Another obvious advantage is the ease of load allocation, especially when we have a monster database server. From the technical point of view, cumbersome multithreading problems can also be conveniently passed on. In choosing to implement content caching or data caching, there are many factors that have to be taken into account, and it is the special requirements of the program that is being developed.

A dependency that deserves attention:

The. NET Framework provides us with several common cache dependencies: time, files, databases. But because of Microsoft's consistent division, we can't create a new type of dependency (SqlCacheDependency function how weak ...) )。 Enterprise Library custom Dependencies is a good idea, we just need to inherit the Icacheitemexpiration interface!

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.