title: IMemoryCache does not save data at application startup
body: <p>I created a fresh ASP.NET Core Web API project. Here is <code>ConfigureServices</code> in Startup.cs:</p>
  
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
          services.AddMemoryCache();
          var serviceProvider = services.BuildServiceProvider();
          var cache = serviceProvider.GetService&lt;IMemoryCache&gt;();
  
          cache.Set("key1", "value1");
          //_cahce.Count is 1
      }
  </code></pre>
  
  <p>As you see I add an item to IMemoryCache. Here is my controller:</p>
  
  <pre><code>[Route("api/[controller]")]
  [ApiController]
  public class ValuesController : ControllerBase
  {
      private readonly IMemoryCache _cache;
      public ValuesController(IMemoryCache cache)
      {
          _cache = cache;
  
      }
      [HttpGet("{key}")]
      public ActionResult&lt;string&gt; Get(string key)
      {
          //_cahce.Count is 0
          if(!_cache.TryGetValue(key, out var value))
          {
              return NotFound($"The value with the {key} is not found");
          }
  
          return value + "";
      }
  }
  </code></pre>
  
  <p>When I request <code>https://localhost:5001/api/values/key1</code>, the cache is empty and I receive a not found response. </p>