Пример #1
0
        public async Task <IList <ChapterItemDto> > GetTableOfConents(string projectId, string branchName)
        {
            if (branchName == null || branchName == "undefined")
            {
                branchName = await GetDefaultBranch(projectId);
            }

            IList <ChapterItemDto> toc = null;

            if (!_cacheService.TryGetTableOfContents(projectId, branchName, out toc))
            {
                var branch = await _branchesClient.Get(projectId, branchName);

                if (branch != null)
                {
                    var mkDocsConfiguration = ReadMkDocsConfiguration(branch.MkDocsYaml);
                    toc = GetChapterItems(mkDocsConfiguration);

                    var cacheEntryOptions = new MemoryCacheEntryOptions()
                                            .SetSlidingExpiration(TimeSpan.FromMinutes(10));

                    _cacheService.AddTableOfContentsToCache(projectId, branchName, toc);
                }
            }

            return(toc);
        }