简体   繁体   中英

What should I prefer and which is faster to access, HttpContext.Application or HttpContext.Cache

I am getting huge amount of data which is frequently used and getting updated too on application start in MVC application. I would like to know,

  1. Which is faster to access, HttpContext.Application or HttpContext.Cache . What should I prefer.

  2. Where does HttpContext.Cache creates memory? in RAM or in Cache Memory of Server..?

Conceptually speaking..

Application is intended for data that is set ONCE per application (not necessarily at startup, maybe at point of first requirement), this exists across all user sessions/logins.

Cache is intended for data that MAY change, but can be valid for a cached period, after the period of time it will need to be re-fetched anyway.

Since you mention that your application needs to hold on to data that is being updated, this does not sound like a use for the Application object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM