public async Task <IActionResult> GetAllKeywords() { List <KeywordInfoModel> lstKeywords = null; this.MemoryCache.TryGetValue <List <KeywordInfoModel> > (Constants.ALLVIDEOS_KEYWORDS, out lstKeywords); if (lstKeywords == null) { AzureVideoIndexerHelper helper = new AzureVideoIndexerHelper(this.AzureConfiguration, this.CreateAuthorizedHttpClient()); lstKeywords = await helper.GetAllKeywords(); } return(Ok(lstKeywords.OrderByDescending(p => p.Appeareances).ToList())); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { await Task.Yield(); AzureVideoIndexerHelper helper = new AzureVideoIndexerHelper(this.AzureConfiguration, this.HttpClientFactory.CreateClient()); var taskGetAllPersonsData = helper.GetAllPersonsData(); var taskGetAllKeywordsAction = helper.GetAllKeywords(); Task.WaitAll(new Task[] { taskGetAllPersonsData, taskGetAllKeywordsAction }); this.MemoryCache.Set <GetAllPersonsModel>(Constants.ALLPERSONS_INFO, taskGetAllPersonsData.Result); this.MemoryCache.Set <List <KeywordInfoModel> >(Constants.ALLVIDEOS_KEYWORDS, taskGetAllKeywordsAction.Result); await Task.Delay(TimeSpan.FromMinutes(5)); } }