Exemple #1
0
        public async Task <IEnumerable <int> > GetTopArticleIdsAsync()
        {
            var cacheKey = "HackerNewsServiceCaching.GetTopStoriesAsync";

            if (_memoryCache.TryGetValue <IEnumerable <int> >(cacheKey, out var storyTask))
            {
                return(storyTask);
            }
            else
            {
                var topStories = await _innerHackerNewsService.GetTopArticleIdsAsync();

                _memoryCache.Set(cacheKey, topStories, TimeSpan.FromMinutes(10));
                return(topStories);
            }
        }