.net core distributed memory cache session timeout code example
Example 1: c# .net core memory cache
[HttpGet]
public string Get()
{
cache.Set(“MyKey”, DateTime.Now.ToString());
return “This is a test method...”;
}
Example 2: c# .net core memory cache
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMemoryCache();
}