Programming Technology cache writing (2)

Source: Internet
Author: User
The last time I discussed various code implementations of cache read/write. This article is about the last issue and continues to look at our cache usage in those years. The last time I discussed various code implementations of cache read/write. This article is about the last issue and continues to look at our cache usage in those years.

I. cache push

Someone asked me last time. During the first loading, our cache is empty. how can we push the cache.

RunTimeCache is generally used for standalone Web scenarios. In this case:

1: We can refresh in the startup event

Void Application_Start (object sender, EventArgs e) {// Refresh}

2: write a refresh cache page, and manually refresh the page after it goes online, or automatically call the refresh page when it is released, or manually trigger it by the user.

Distributed Cache (Redis and memcached:

For example, it may take some time to cache dozens of servers.

This kind of push is more complicated. some write an application to run, and some write a set of framework mechanisms to process (more intelligent ).

The purpose is to pre-load all the caches before going online.

II. multi-level cache

2.1 Introduction

We know that the CPU and memory are generally equipped with a level-1 cache and level-2 cache to increase the switching speed.

In this way, when the CPU calls a large amount of data, the memory can be directly called from the CPU cache to speed up reading.

The characteristics of multi-level cache are obtained based on the CPU cache:

1: each level of cache stores a part of the next level of cache.

2: the read speed decreases in sequence by level, the cost also decreases in sequence, and the capacity increases in sequence.

3: When the current level is not hit, it will go to the next level for search.

In enterprise application-level development, the use of multi-level caching is the same purpose and design, but the granularity is more coarse and flexible.

Sort the cache type charts for the lv1-lv6 in order of speed:

III. multi-layer cache

The multi-layer cache concept has been used in many places:

1: The multi-level cache we mentioned above is one type. the content is stored in different layers based on the read frequency level, and the closer the frequency is.

2: There is also a multi-layer cache index approach, such as B-tree search, which can improve the retrieval efficiency.

3: The client cache, CDN cache, reverse proxy cache, and server cache are also multi-layer caches.

IV. Summary

In terms of use, you can make a variety of combinations based on the actual scenario. This article is more theoretical and detailed.

Such as distributed cache usage, cache replacement policies and algorithms, and cache expiration mechanisms. It will be added later.

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.