public async Task <ReadOnlyCollection <Category> > GetSubcategoriesAsync(int parentId, int maxAmountOfProducts) { string cacheFileName = String.Format("Categories-{0}-{1}", parentId, maxAmountOfProducts); try { // Case 1: Retrieve the items from the cache return(await _cacheService.GetDataAsync <ReadOnlyCollection <Category> >(cacheFileName)); } catch (FileNotFoundException) { } // Retrieve the items from the service var categories = await _productCatalogService.GetCategoriesAsync(parentId, maxAmountOfProducts); // Save the items in the cache await _cacheService.SaveDataAsync(cacheFileName, categories); return(categories); }