public async Task <StoryCollection> GetBestStories() { StoryCollection colStory = null; colStory = await _hackerNewsService.GetBestStoriesAsync(); return(colStory); }
public async Task <IEnumerable <BestStory> > GetBestStoriesAsync() { IEnumerable <BestStory> result = null; if (!cache.TryGetValue(CACHE_KEY, out result)) { var bestStories = await hackerNewsService.GetBestStoriesAsync(); result = bestStories.OrderByDescending(story => story.Score).Take(storiesToRetrieve); var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(cacheLimit)); cache.Set(CACHE_KEY, result, cacheEntryOptions); } return(result); }