asp.net-core – 我需要在ASP.NET Core for Cache中调用AddMemoryCache吗?

前端之家收集整理的这篇文章主要介绍了asp.net-core – 我需要在ASP.NET Core for Cache中调用AddMemoryCache吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在最新的.net Core(1.0.0-preview2-003131)中,我对开始使用的服务以及它们的默认设置感到困惑.

具体来说,我注意到在一个新的核心Web项目中,AddMvc()被调用但Add AddMemoryCache()不是(两者似乎都可用于应用程序).更进一步,似乎在帮助文档:https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory中它显示AddMemoryCache.

AddMemoryCache()以某种方式在其他地方加载吗?如果没有,为什么缓存似乎工作如果没有添加服务?

解决方法

Does AddMemoryCache() somehow get loaded someplace else?

是.当您调用services.AddMvc()时,它会间接添加,因为它在tag helpers stack中使用.

猜你在找的.NET Core相关文章