Cache! Cache! Cache !!! (1)

Source: Internet
Author: User

Preface

I believe most developers are familiar with caching. Many developers use predefined or custom caching in software development and obtain the expected applications.ProgramPerformance improvement. This article and subsequentArticleThis section describes and discusses in detail the cache implementation mechanism under the. NET system, and discusses its advantages and disadvantages.

 

Actual value of Using Cache:
InKevinhoffman,LonnykrugerWritten in:Developers often need to temporarily store data (temporary data) to a storage media for quick access. this temporary data storage is called cache. if developers use the cache properly, the application performance can be greatly improved.

The above is a perfect definition of cache. For now, the data can be quickly and conveniently provided to the core for processing.CodeIt has become an important design requirement ., Quick is to enhance the user experience and reduce the system pressure easily. The cache can complete the task, although not so perfect.

 

Almost all cache mechanisms share the following things:
1. provides temporary data storage to check whether there is uncertainty in the cached data.
2. You can set the cache priority.
3. cache dependencies can be formulated. cache data is unavailable if the dependency expires.
4. The core of the cache is map.

 

Some discussions about cache:

Temporary cache vs persistent cache:
In fact, theoretically, Microsoft. NET's cache solution is the most perfect cache implementation, but it is because of its textbook implementation that many programmers complain constantly. One possible paradox is that the raw data is inserted into the cache and discarded due to system memory shortage, though it is designed to relieve pressure. This is not a problem with Microsoft, but a greedy appetite and improper use by programmers.
In many open-source cache mechanisms, the persistent cache method is used for implementation. In fact, these are not so much cache, I think they are more like an enhanced session, which will give the cache priority, the cache dependency mechanism is installed on it. It is simple and easy to develop (. NET cache involves a large number of underlying unmanaged code ).

Content cache vs data cache:
Content caching is not the only choice, and data caching does not have any advantages. Although the performance is slightly insufficient, storing data in the database saves the trouble of clearing the cache ,. Another obvious advantage is the ease of load distribution, especially when we have a monster database server. Technically speaking, troublesome multithreading problems can also be easily passed on. There are many factors that have to be considered when selecting whether to implement content caching or data caching. the special requirements of the developed program are included.

Important dependencies:
. NET Framework provides several common cache dependencies: time, file, and database. However, due to Microsoft's consistent performance score, we cannot create new types of dependencies (why is the sqlcachedependency function weak ...). Enterprise Library custom dependency is a good idea. We only need to inherit the icacheitemexpiration interface! Although I am still dependent on the life cycle and the amount of effort to clean up.

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.