From e2ddaaa56165ac43081cb8253948ff8dcd0a2548 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 21 Apr 2020 09:47:05 +0300 Subject: [PATCH] Docs module cache clear: refactor & simplify --- .../Documents/DocumentAdminAppService.cs | 33 ++++--------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs index ddebc1b5d5..25e5c1d9df 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs @@ -54,31 +54,20 @@ namespace Volo.Docs.Admin.Documents var project = await _projectRepository.GetAsync(input.ProjectId); var languageCacheKey = CacheKeyGenerator.GenerateProjectLanguageCacheKey(project); - var languageConfig = await _languageCache.GetAsync(languageCacheKey, true); - CheckNotNullCacheValue(languageConfig); + await _languageCache.RemoveAsync(languageCacheKey, true); var versionCacheKey = CacheKeyGenerator.GenerateProjectVersionsCacheKey(project); - var versions = await _versionCache.GetAsync(versionCacheKey, true); - CheckNotNullCacheValue(versions); - - await _languageCache.RemoveAsync(languageCacheKey, true); await _versionCache.RemoveAsync(versionCacheKey, true); var documents = await _documentRepository.GetListByProjectId(project.Id); - foreach (var languageCode in languageConfig.Languages) + foreach (var document in documents) { - foreach (var version in versions) - { - foreach (var document in documents) - { - var documentUpdateInfoCacheKey = CacheKeyGenerator.GenerateDocumentUpdateInfoCacheKey(project, document.Name, languageCode.Code, version.Name); - await _documentUpdateCache.RemoveAsync(documentUpdateInfoCacheKey); - - document.LastCachedTime = DateTime.MinValue; - await _documentRepository.UpdateAsync(document); - } - } + var documentUpdateInfoCacheKey = CacheKeyGenerator.GenerateDocumentUpdateInfoCacheKey(project, document.Name, document.LanguageCode, document.LanguageCode); + await _documentUpdateCache.RemoveAsync(documentUpdateInfoCacheKey); + + document.LastCachedTime = DateTime.MinValue; + await _documentRepository.UpdateAsync(document); } } @@ -162,14 +151,6 @@ namespace Volo.Docs.Admin.Documents } } - private void CheckNotNullCacheValue(object cacheValue) - { - if (cacheValue == null) - { - throw new UserFriendlyException(L["CacheNullExceptionMessage"]); - } - } - private async Task UpdateDocumentUpdateInfoCache(Document document) { var cacheKey = $"DocumentUpdateInfo{document.ProjectId}#{document.Name}#{document.LanguageCode}#{document.Version}";