public async Task <IEnumerable <WeatherForecast> > FetchAsync(CancellationToken cancellationToken) { var forecasts = new List <WeatherForecast>(); for (var index = 1; index < 5; index++) { var date = DateTime.Now.Date.AddDays(index); // Get cached daily forecast if it exists and fetch if not. var forecast = await _distributedCache .GetOrSetJsonObjectAsync($"single-weather-forecast:{date.ToShortDateString()}", () => _weatherService.FetchForecastAsync(date, cancellationToken), _entryOptions, cancellationToken); forecasts.Add(forecast); } return(forecasts.AsEnumerable()); }