diff --git a/AsbCloudInfrastructure/Services/Cache/CacheTable.cs b/AsbCloudInfrastructure/Services/Cache/CacheTable.cs index e2f9e4ba..2fefe662 100644 --- a/AsbCloudInfrastructure/Services/Cache/CacheTable.cs +++ b/AsbCloudInfrastructure/Services/Cache/CacheTable.cs @@ -24,7 +24,8 @@ namespace AsbCloudInfrastructure.Services.Cache public int Refresh() { - cached.Clear(); + if(cached.Any()) + cached.Clear(); var dbEntities = context.Set().ToList(); cached.AddRange(dbEntities); data.refreshDate = DateTime.Now; @@ -33,7 +34,8 @@ namespace AsbCloudInfrastructure.Services.Cache public async Task RefreshAsync(CancellationToken token = default) { - cached.Clear(); + if (cached.Any()) + cached.Clear(); var dbEntities = await context.Set().ToListAsync(token).ConfigureAwait(false); cached.AddRange(dbEntities); data.refreshDate = DateTime.Now;