. NET self-caching cache usage

Source: Internet
Author: User

For the data is relatively large, often to be taken out of the database, you can consider the use. NET comes with cache caches that are easy to use:

//inserting a cache into memorySystem.Web.HttpRuntime.Cache.Insert ("Key","value");//Fetch Cache (first method)varCache1 = system.web.httpruntime.cache["Key"];//Fetch Cache (second method)varCache2 = System.Web.HttpRuntime.Cache.Get ("Key");//If there are no values in the cache, createif(Cache2 = =NULL) {Cache2="Cached Values"; System.Web.HttpRuntime.Cache.Insert ("Key", cache2);}//other places if you have additions, updates, or deletions, you need to update the cached values again//before updating, you can remove the original cache valueSystem.Web.HttpRuntime.Cache.Remove ("Key");//AddSystem.Web.HttpRuntime.Cache.Insert ("Key","value"+"new Value Added");//UpdateSystem.Web.HttpRuntime.Cache.Insert ("Key","the updated value value");//DeleteSystem.Web.HttpRuntime.Cache.Insert ("Key","value"+"new value after deletion");

. NET self-caching cache usage

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.