Docs module cache clear: refactor & simplify

pull/3680/head
Yunus Emre Kalkan 5 years ago
parent c05eb0ecf1
commit e2ddaaa561

@ -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}";

Loading…
Cancel
Save