public async Task <RestaurantInfoResponse> GetRestaurantInfo(string postCode) { try { if (string.IsNullOrWhiteSpace(postCode)) { _logger.LogError("postCode is null {postCode}", postCode); return(null); } var response = new RestaurantInfoResponse(); //check if item exists in redis var cache = await GetFromCache(postCode); if (cache != null) { return(response = cache); } //Get info from info provider var restaurant = await _restaurant.GetRestaurantInfoByPostCode(postCode); if (restaurant != null && restaurant.MetaData.ResultCount > 0) { response.Datas.AddRange(restaurant.Restaurants.Select(x => new InfoData() { Name = x.Name, Rating = x.Rating, FoodTypes = x.CuisineTypes }).ToList()); await _cache.AddItem(postCode, JsonConvert.SerializeObject(response), TimeSpan.FromMinutes(30).TotalSeconds); return(response); } return(response); } catch (Exception ex) { _logger.LogError(ex, "Error occured in GetRestaurantInfo"); return(null); } }