Is System.Web.Caching or System.Runtime.Caching preferable for a .NET 4 web application

前端 未结 2 1444
半阙折子戏
半阙折子戏 2021-01-30 20:49

I am adding caching to an ASP.NET web application. This is .NET 4, so I can use the classes in the System.Runtime.Caching namespace (which, as I understand it, was added to pro

2条回答
  •  深忆病人
    2021-01-30 21:31

    System.Runtime.Caching allows you to cache across all .Net apps, not just the IIS worker process. So if you have a requirement that will access the cache in multiple scenarios, use System.Runtime. Also you can check this cache adapter which allows you to swap between runtime, web, and app fabric caching. https://bitbucket.org/glav/cacheadapter

    One more thing, if you have a multi-server farm, with a load balanced configuration make sure you have sticky-sessions or a distributed cache model.

提交回复
热议问题