Pros/Cons of different ASP.NET Caching Options

前端 未结 3 483
自闭症患者
自闭症患者 2020-12-04 07:29

I recently asked a question about caching application data in an ASP.NET MVC WebAPI application and it led me to a new question. What are the pros/cons of different caching

3条回答
  •  情歌与酒
    2020-12-04 08:14

    Regarding MemoryCache vs ASP.NET Cache: they provide very similar functionality. In an ASP.NET 4 application, I'd generally prefer the ASP.NET Cache, if for no other reason, then because of a bug in .NET 4, which is apparently fixed in .NET 4.5.

    Static fields are appropriate to store shared data that does not need an expiration policy.

    Application state isn't much more than a static dictionary with locking semantics that is compatible with classic ASP - I'd only use it for backwards compatibility with legacy classic ASP code.

提交回复
热议问题