HttpRuntime Cache vs. static dictionary/fields

后端 未结 3 1851
小鲜肉
小鲜肉 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:23

    Objects in HttpRuntime.Cache have unknown expiry periods unless explicitly set (meaning that objects can expire any time), whereas objects within your HashTable live for as your application pool is alive (unless you manually remove an entry). The HttpRuntime.Cache also allows you to set various other characteristics, such as (optional) cache item priority and expiry time.

提交回复
热议问题