private async Task EnsureRepoFeed() { if (_repoFeed == null) { _repoFeed = await GetOrCreateRepoFeedCacheAsync(); } }
private async Task <ProjectRepoFeed> GetOrCreateRepoFeedCacheAsync() { ProjectRepoFeed result = null; if (!_cache.TryGetValue <ProjectRepoFeed>(_config.RepoFeedCacheKey, out result)) { result = await _feedService.GetRepoFeed(); if (result != null) { _cache.Set( _config.RepoFeedCacheKey, result, new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromSeconds(_config.CacheDurationInSeconds)) ); } } if (result == null) { throw new InvalidOperationException("failed to retrieve project feed"); } return(result); }