In the latest .net Core (1.0.0-preview2-003131), I'm confused about the services that get started and also what their defaults might be.
In specific, I notice that on a new core web project, AddMvc() is called but Add AddMemoryCache() is not (both seem to be available to the app). Going one step further, it seems that in the help doc: https://docs.microsoft.com/en-us/aspnet/core/performance/caching/memory its shows AddMemoryCache.
Does AddMemoryCache() somehow get loaded someplace else? if not, why does cache seem to work if the service is not added?
ASP.NET Core supports several different caches. The simplest cache is based on the IMemoryCache. IMemoryCache represents a cache stored in the memory of the web server. Apps running on a server farm (multiple servers) should ensure sessions are sticky when using the in-memory cache.
To manually cache application data, you can use the MemoryCache class in ASP.NET. ASP.NET also supports output caching, which stores the generated output of pages, controls, and HTTP responses in memory. You can configure output caching declaratively in an ASP.NET Web page or by using settings in the Web. config file.
Does AddMemoryCache() somehow get loaded someplace else?
Yes. It's indirectly added when you call services.AddMvc()
, as it's used in the tag helpers stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With