private async Task RefreshCache(CancellationToken cancellationToken) { try { logger.LogInformation("{0} starting location cache refresh", nameof(LocationCacheHostedService)); await cache.SetAsync(LocationCacheNames.Countries, JsonSerializer.SerializeToUtf8Bytes(await listsRepository.GetCountries()), cancellationToken); await cache.SetAsync(LocationCacheNames.StateProvinces, JsonSerializer.SerializeToUtf8Bytes(await listsRepository.GetStateProvinces()), cancellationToken); await cache.SetAsync(LocationCacheNames.Jurisdictions, JsonSerializer.SerializeToUtf8Bytes(await listsRepository.GetJurisdictions()), cancellationToken); logger.LogInformation("{0} finished location cache refresh", nameof(LocationCacheHostedService)); } catch (Exception e) { logger.LogError(e, "{0} finished location cache refresh with error", nameof(LocationCacheHostedService)); } }