Discussion on the design of cache function in MVC Project

Source: Internet
Author: User

This article collects some information about why caching is needed in the project, how to use it, and how to consider the design of the cache in real-world development.

Why do we need to discuss caching?

Caching is a problem that must be considered in a medium-sized system. In order to avoid each request to access the background resources (such as the database), we generally consider some of the updates are not very frequent, can be reused data, in a certain way to temporarily save, the subsequent requests can be directly accessed by the situation of these saved data. This mechanism is called a caching mechanism.

Depending on the location of the cache, the zone can be divided into:

1. Client cache (cached on the user's client, e.g. browser)

2, the server is out of stock (cached in the server, can be slow in memory, can also be slow to exist in the file, and can be further differentiated into local cache and distributed cache two)

It should be said that the design of the cache is a more complex learning, the main issues to consider include:

1. Do you want to cache?

2. What data to cache?

3. How much data to cache?

4, how long to cache?

5. How to update the cache (manual or automatic)

6. Where is the cache placed?

This article takes a look at the above questions about how to use the caching feature in a real-world project.

Common caching feature support is shown in the following areas:

1. You can define the output cache (page cache) directly above the controller. Control cache? )

2, through the method of caching policy, flexibly define the settings of the cache (new function)

3. Support cache dependencies to be notified when external resources change, and update the cache

4, support the use of the cache API, but also support some third-party caching schemes (such as distributed cache)

For the common MVC framework, suppose there is an entity class employee, we can change the employee additions and deletions

1. Using Output caching

For example, we have

Reference link: Talk about the design of cache function in MVC Project

Discussion on the design of cache function in MVC Project

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.