我已经将我的应用程序从MemoryCache切换到了DistributedSqlServerCache。在注释掉services.AddMemoryCache()之后,我注意到IMemoryCache仍然被注入到我的类中。我使用aspnet核心2.1.
将缓存添加到服务的代码:
//services.AddMemoryCache();
services.AddDistributedSqlServerCache(o =>
{
o.ConnectionString = ConnectionString;
o.SchemaName = "dbo";
o.TableName = "tbSessionCache";
});
证明它仍然被引用:
这一切为什么要发生?我想我可能不知道这是怎么回事。非常感谢!
发布于 2018-06-22 02:53:16
MVC在配置Razor视图引擎时添加了默认的内存缓存实现。它是由缓存标记助手:https://github.com/aspnet/Mvc/blob/17d2545b557863955cb5838fa16c6318931ac659/src/Microsoft.AspNetCore.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs#L224使用的。
https://stackoverflow.com/questions/50985617
复制相似问题