/// <summary> /// Returns the document from the cache or creates a new one. The result should not be updated. /// </summary> private async Task <RolesDocument> GetRolesAsync() { return(await _scopedDistributedCache.GetOrSetAsync(() => { return _sessionHelper.GetForCachingAsync <RolesDocument>(); })); }
/// <summary> /// Returns the document from the cache or creates a new one. The result should not be updated. /// </summary> public async Task <LayersDocument> GetLayersAsync() { if (!_memoryCache.TryGetValue <LayersDocument>(LayersCacheKey, out var layers)) { var changeToken = ChangeToken; layers = await _sessionHelper.GetForCachingAsync <LayersDocument>(); layers.IsReadonly = true; _memoryCache.Set(LayersCacheKey, layers, changeToken); } return(layers); }
private async Task <SitemapDocument> GetDocumentAsync() { if (!_memoryCache.TryGetValue <SitemapDocument>(SitemapsDocumentCacheKey, out var document)) { var changeToken = ChangeToken; document = await _sessionHelper.GetForCachingAsync <SitemapDocument>(); foreach (var sitemap in document.Sitemaps.Values) { sitemap.IsReadonly = true; } _memoryCache.Set(SitemapsDocumentCacheKey, document, changeToken); } return(document); }
/// <summary> /// Returns the document from the cache or creates a new one. The result should not be updated. /// </summary> public async Task <TemplatesDocument> GetTemplatesDocumentAsync() { if (!_memoryCache.TryGetValue <TemplatesDocument>(CacheKey, out var document)) { var changeToken = ChangeToken; document = await _sessionHelper.GetForCachingAsync <TemplatesDocument>(); foreach (var template in document.Templates.Values) { template.IsReadonly = true; } _memoryCache.Set(CacheKey, document, changeToken); } return(document); }
/// <summary> /// Returns the document from the cache or creates a new one. The result should not be updated. /// </summary> public async Task <AdminMenuList> GetAdminMenuListAsync() { if (!_memoryCache.TryGetValue <AdminMenuList>(AdminMenuCacheKey, out var adminMenuList)) { var changeToken = ChangeToken; adminMenuList = await _sessionHelper.GetForCachingAsync <AdminMenuList>(); foreach (var adminMenu in adminMenuList.AdminMenu) { adminMenu.IsReadonly = true; } _memoryCache.Set(AdminMenuCacheKey, adminMenuList, changeToken); } return(adminMenuList); }
/// <summary> /// Returns the document from the cache or creates a new one. The result should not be updated. /// </summary> private async Task <QueriesDocument> GetDocumentAsync() { if (!_memoryCache.TryGetValue <QueriesDocument>(QueriesDocumentCacheKey, out var queries)) { var changeToken = ChangeToken; queries = await _sessionHelper.GetForCachingAsync <QueriesDocument>(); foreach (var query in queries.Queries.Values) { query.IsReadonly = true; } _memoryCache.Set(QueriesDocumentCacheKey, queries, changeToken); } return(queries); }
/// <summary> /// Returns the document from the cache or creates a new one. The result should not be updated. /// </summary> /// <inheritdoc/> public async Task <BackgroundTaskDocument> GetDocumentAsync() { if (!_memoryCache.TryGetValue <BackgroundTaskDocument>(CacheKey, out var document)) { var changeToken = ChangeToken; document = await _sessionHelper.GetForCachingAsync <BackgroundTaskDocument>(); foreach (var settings in document.Settings.Values) { settings.IsReadonly = true; } _memoryCache.Set(CacheKey, document, changeToken); } return(document); }
/// <summary> /// Returns the document from the cache or creates a new one. The result should not be updated. /// </summary> private async Task <RolesDocument> GetRolesAsync() { if (!_memoryCache.TryGetValue <RolesDocument>(Key, out var document)) { var changeToken = _signal.GetToken(Key); document = await _sessionHelper.GetForCachingAsync <RolesDocument>(); foreach (var role in document.Roles) { role.IsReadonly = true; } _memoryCache.Set(Key, document, changeToken); } return(document); }
/// <summary> /// Returns the document from the cache or creates a new one. The result should not be updated. /// </summary> public async Task <ShortcodeTemplatesDocument> GetShortcodeTemplatesDocumentAsync() { if (!_memoryCache.TryGetValue <ShortcodeTemplatesDocument>(CacheKey, out var document)) { var changeToken = ChangeToken; bool cacheable; (cacheable, document) = await _sessionHelper.GetForCachingAsync <ShortcodeTemplatesDocument>(); if (cacheable) { foreach (var template in document.ShortcodeTemplates.Values) { template.IsReadonly = true; } _memoryCache.Set(CacheKey, document, changeToken); } } return(document); }
/// <summary> /// Gets a single document (or create a new one) for caching and that should not be updated. /// </summary> public Task <ContentDefinitionRecord> GetContentDefinitionAsync() => _sessionHelper.GetForCachingAsync <ContentDefinitionRecord>();