December 2019
Intermediate to advanced
598 pages
12h 21m
English
Now,we are going to make use of the questions cache in the GetQuestion method in our API controller:
public void ConfigureServices(IServiceCollection services){ ... services.AddMemoryCache(); services.AddSingleton<IQuestionCache, QuestionCache>();}
We enable the ASP.NET Core memory cache and then register our cache as a singleton in the dependency injection system. This means that a single instance of our class will be created for the lifetime of the app. So, separate HTTP requests will access the same class instance and, ...