public async Task <IEnumerable <IArtistInfo> > GetArtistInfosAsync(IEnumerable <int> ids) { List <IArtistInfo> result = new List <IArtistInfo>(); if (!ids.Any()) { result = await GetAllArtistInfosAsync(); } else { List <int> sourceLookupIds = new List <int>(); foreach (var id in ids) { if (_artistInfoCache.TryGetArtistInfo(id, out IArtistInfo artistInfo)) { result.Add(artistInfo); } else { sourceLookupIds.Add(id); } } if (sourceLookupIds.Any()) { IEnumerable <IArtistInfo> sourceArtistInfos = await _sourceRadiocomArtistInfoRepository.GetArtistInfosAsync(sourceLookupIds); result.AddRange(sourceArtistInfos); _logger.LogInformation(sourceArtistInfos.Count().ToString()); await _artistInfoCache.StoreArtistInfosAsync(sourceArtistInfos); } } return(result); }
public Task <IEnumerable <IArtistInfo> > ProcessArtistInfosRequest(IArtistInfosRequest artistInfosRequest) { return(_radiocomArtistInfoRepository.GetArtistInfosAsync(artistInfosRequest.ArtistIds)); }