c# .net core memory cache

C#
public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
    services.AddMemoryCache();
}
[HttpGet]
public string Get()
{
    cache.Set(“MyKey”, DateTime.Now.ToString());
    return “This is a test method...”;
}
private IMemoryCache cache;
public MyCacheController(IMemoryCache cache)
{    
        this.cache = cache;
}

Source

Also in C#: