示例#1
0
        public async Task <StoryCollection> GetBestStories()
        {
            StoryCollection colStory = null;

            colStory = await _hackerNewsService.GetBestStoriesAsync();

            return(colStory);
        }
示例#2
0
        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);
        }