Differences between Application and Cache in ASP. NET

Source: Internet
Author: User

There are many ways to store data in asp.net, including application, session, cache, cookie, and viewstate. The application and cache application scopes are similar in usage. Here we will mainly compare these two methods.

Similarities:

1. the effective scope of the variables stored by both are the entire application lifecycle.

2. Both of them can store objects.

Differences:

1. The application is used in the asp stage. After being upgraded to. net, the cache is used, but the application is retained for forward compatibility.

2. the cache is more flexible and powerful than the application. Cache can set the priority of each item. When the server memory is insufficient, the cache will be compressed and some items that are not used for a long time or have a low priority will be removed from the cache.

3. You can set the dependency of an item in the cache. The dependent object can be another item in the cache or a file. When the dependent item or file changes, the content of this item is automatically updated or removed.

4. in terms of efficiency, the cache is higher than the application, in part because the lock and unlock needs to be called during the concurrent access of appliction, which locks all application variables, the cache implements mutual locks for concurrent access. You can lock only one item at a time instead of the entire cache.

Related Article

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.