Exemplo n.º 1
0
        private async Task <List <string> > GetAllSiteFoldersFolders()
        {
            var result = await _cacheHelper.GetSiteFoldersFromCache();

            if (result != null)
            {
                return(result);
            }

            result = await SiteQueries.GetAllSiteFolders();

            await _cacheHelper.AddSiteFoldersToCache(result, _cachingOptions.FolderListCacheDuration);

            return(result);
        }
        private async Task <List <string> > GetAllSiteFoldersFolders()
        {
            var listCacheKey = "folderList";

            if (_cache.Get(listCacheKey) is List <string> result)
            {
                _log.LogDebug("Folder List retrieved from cache with key \"{cacheKey}\".", listCacheKey);
                return(result);
            }

            result = await SiteQueries.GetAllSiteFolders();

            var cacheEntryOptions = new MemoryCacheEntryOptions()
                                    .SetAbsoluteExpiration(_cachingOptions.FolderListCacheDuration);

            _log.LogDebug("Caching folder list with keys \"{cacheKey}\".", listCacheKey);
            _cache.Set(listCacheKey, result, cacheEntryOptions);

            return(result);
        }