Don't preload if it's a development envrionment

This commit is contained in:
Jeff Leung 2024-01-05 16:51:40 -08:00
parent 14f8ea618a
commit 01ccc1ab91
1 changed files with 6 additions and 2 deletions

View File

@ -9,22 +9,26 @@ namespace AS1024.GeoFeed.GeoFeedBuilder
private readonly ILogger<PreLoadGeoFeed> logger;
private readonly IGeoFeedProvider provider;
private readonly IMemoryCache memoryCache;
private readonly IWebHostEnvironment environment;
private const string GeoFeedCacheKey = "GeoFeedData";
public PreLoadGeoFeed(ILogger<PreLoadGeoFeed> logger,
IGeoFeedProvider provider,
IMemoryCache memoryCache)
IMemoryCache memoryCache,
IWebHostEnvironment environment)
{
this.logger = logger;
this.provider = provider;
this.memoryCache = memoryCache;
this.environment = environment;
}
async Task IHostedService.StartAsync(CancellationToken cancellationToken)
{
try
{
await StartPreLoad();
if (environment.IsProduction())
await StartPreLoad();
} catch (Exception ex)
{
logger.LogWarning($"Failed to preload, exception settings below:\n{ex}");