Skip to content

Commit

Permalink
Don't update the search cache if an update is already in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgriff authored Feb 7, 2025
1 parent 8fdc188 commit c693b95
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions GenderPayGap.WebUI/Search/SearchCacheUpdaterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,31 @@ public Task StartAsync(CancellationToken stoppingToken)

private void DoWork(object state)
{
if (updateInProgress)

Check failure on line 30 in GenderPayGap.WebUI/Search/SearchCacheUpdaterService.cs

View workflow job for this annotation

GitHub Actions / Build

The name 'updateInProgress' does not exist in the current context

Check failure on line 30 in GenderPayGap.WebUI/Search/SearchCacheUpdaterService.cs

View workflow job for this annotation

GitHub Actions / Build

The name 'updateInProgress' does not exist in the current context
{
CustomLogger.Information("Cache update postponed - another update is already in progress (SearchRepository.StartCacheUpdateThread)");
return;
}

updateInProgress = true;

Check failure on line 36 in GenderPayGap.WebUI/Search/SearchCacheUpdaterService.cs

View workflow job for this annotation

GitHub Actions / Build

The name 'updateInProgress' does not exist in the current context

Check failure on line 36 in GenderPayGap.WebUI/Search/SearchCacheUpdaterService.cs

View workflow job for this annotation

GitHub Actions / Build

The name 'updateInProgress' does not exist in the current context
CustomLogger.Information("Starting cache update (SearchRepository.StartCacheUpdateThread)");

try
{
SearchRepository.LoadSearchDataIntoCache();

CustomLogger.Information("Finished cache update (SearchRepository.StartCacheUpdateThread)");
}
catch (Exception ex)
{
CustomLogger.Error($"Error during cache update (SearchRepository.StartCacheUpdateThread): {ex.Message} {ex.StackTrace}", ex);
CustomLogger.Error(
$"Error during cache update (SearchRepository.StartCacheUpdateThread): {ex.Message} {ex.StackTrace}",
ex);
}
finally
{
updateInProgress = false;

Check failure on line 53 in GenderPayGap.WebUI/Search/SearchCacheUpdaterService.cs

View workflow job for this annotation

GitHub Actions / Build

The name 'updateInProgress' does not exist in the current context

Check failure on line 53 in GenderPayGap.WebUI/Search/SearchCacheUpdaterService.cs

View workflow job for this annotation

GitHub Actions / Build

The name 'updateInProgress' does not exist in the current context
}

CustomLogger.Information("Finished cache update (SearchRepository.StartCacheUpdateThread)");
}

public Task StopAsync(CancellationToken stoppingToken)
Expand Down

0 comments on commit c693b95

Please sign in to comment.