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 b93b4f6698..8e70be19e4 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 @@ -70,7 +70,7 @@ namespace Volo.Docs.Admin.Documents await _documentUpdateCache.RemoveManyAsync(documentUpdateInfoCacheKeys); - await _documentRepository.ClearCachesAsync(project.Id); + await _documentRepository.UpdateProjectLastCachedTimeAsync(project.Id, DateTime.MinValue); } public virtual async Task PullAllAsync(PullAllDocumentInput input) diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs index 7b985b19d8..7dc8f13147 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs @@ -13,7 +13,8 @@ namespace Volo.Docs.Documents Task> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default); - Task ClearCachesAsync(Guid projectId, CancellationToken cancellationToken = default); + Task UpdateProjectLastCachedTimeAsync(Guid projectId, DateTime cachedTime, + CancellationToken cancellationToken = default); Task FindAsync(Guid projectId, string name, diff --git a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs index 83d1683368..1120e36d01 100644 --- a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs @@ -56,9 +56,10 @@ namespace Volo.Docs.Documents return await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken)); } - public async Task ClearCachesAsync(Guid projectId, CancellationToken cancellationToken = default) + public async Task UpdateProjectLastCachedTimeAsync(Guid projectId, DateTime cachedTime, + CancellationToken cancellationToken = default) { - await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ExecuteUpdateAsync(x => x.SetProperty(d => d.LastCachedTime, DateTime.MinValue), GetCancellationToken(cancellationToken)); + await (await GetDbSetAsync()).Where(d => d.ProjectId == projectId).ExecuteUpdateAsync(x => x.SetProperty(d => d.LastCachedTime, cachedTime), GetCancellationToken(cancellationToken)); } public virtual async Task> GetListAsync(Guid? projectId, string version, string name, CancellationToken cancellationToken = default) diff --git a/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs b/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs index b1a3288ac4..9a3750deb0 100644 --- a/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs @@ -54,12 +54,13 @@ namespace Volo.Docs.Documents return await (await GetMongoQueryableAsync(cancellationToken)).Where(d => d.ProjectId == projectId).ToListAsync(GetCancellationToken(cancellationToken)); } - public async Task ClearCachesAsync(Guid projectId, CancellationToken cancellationToken = default) + public async Task UpdateProjectLastCachedTimeAsync(Guid projectId, DateTime cachedTime, + CancellationToken cancellationToken = default) { var collection = await GetCollectionAsync(cancellationToken); await collection.UpdateManyAsync( Builders.Filter.Eq(x => x.ProjectId, projectId), - Builders.Update.Set(x => x.LastCachedTime, DateTime.MinValue), + Builders.Update.Set(x => x.LastCachedTime, cachedTime), cancellationToken: GetCancellationToken(cancellationToken) ); } diff --git a/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocumentRepository_Tests.cs b/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocumentRepository_Tests.cs index a1cdaa6269..742f80fe17 100644 --- a/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocumentRepository_Tests.cs +++ b/modules/docs/test/Volo.Docs.TestBase/Volo/Docs/DocumentRepository_Tests.cs @@ -37,9 +37,9 @@ namespace Volo.Docs } [Fact] - public async Task ClearCachesAsync() + public async Task UpdateProjectLastCachedTimeAsync() { - await DocumentRepository.ClearCachesAsync(DocsTestData.ProjectId); + await DocumentRepository.UpdateProjectLastCachedTimeAsync(DocsTestData.ProjectId, DateTime.MinValue); var documentsAfterClear = await DocumentRepository.GetListByProjectId(DocsTestData.ProjectId); documentsAfterClear.ForEach(d => d.LastCachedTime.ShouldBe(DateTime.MinValue)); }