An analysis of the differences between Application and Cache in ASP.NET

  • 2020-05-09 18:25:00
  • OfStack

Similarities:
The valid range of the stored variables is the entire life cycle of the application.
2. 2 can store objects.

Difference:
1. application was used in the asp phase and later upgraded to.net, cache was used, but application was retained for forward compatibility.

2. cache is more flexible and powerful than application. cache can set the priority of every item. When the server is out of memory, cache will be compressed and 1 long-unused or low-priority item will be removed from cache.
3. In cache, you can set the dependency of an item, which can be another item in cache or a certain file. When the dependent item or file changes, the content of this item is automatically updated or removed.
4. In terms of efficiency, cache is more efficient than application, partly because appliction needs to call lock and unlock in concurrent access, which locks all the application variables, while cache internally implements interlock in concurrent access, locking only one item at a time, instead of the whole cache.
Resources: http: / / www eggheadcafe. com articles / 20030405. asp


Related articles: