HttpRuntime Cache vs. static dictionary/fields

后端 未结 3 1844
小鲜肉
小鲜肉 2021-02-15 15:22

What are the main pros and cons for using HttpRuntime Cache against using simple static field?

I need to store data in scope of entire

3条回答
  •  醉梦人生
    2021-02-15 16:14

    with the cache you can easily set an enddate to the validity; the cache object expires the content automaticly.

    also the cache can be given a priority, that less important items can be given a low priority so when the server gets high load, that item is removed first

    with cahce however you allways have to do some extra effort in your unit test because the httpcontext isn't available during unit tests.

提交回复
热议问题