From 01ccc1ab916de8c06ac3be7d3ca59fed90099a54 Mon Sep 17 00:00:00 2001 From: Jeff Leung Date: Fri, 5 Jan 2024 16:51:40 -0800 Subject: [PATCH] Don't preload if it's a development envrionment --- AS1024.GeoFeed/GeoFeedBuilder/PreloadGeoFeed.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AS1024.GeoFeed/GeoFeedBuilder/PreloadGeoFeed.cs b/AS1024.GeoFeed/GeoFeedBuilder/PreloadGeoFeed.cs index c73d363..28f76b8 100644 --- a/AS1024.GeoFeed/GeoFeedBuilder/PreloadGeoFeed.cs +++ b/AS1024.GeoFeed/GeoFeedBuilder/PreloadGeoFeed.cs @@ -9,22 +9,26 @@ namespace AS1024.GeoFeed.GeoFeedBuilder private readonly ILogger logger; private readonly IGeoFeedProvider provider; private readonly IMemoryCache memoryCache; + private readonly IWebHostEnvironment environment; private const string GeoFeedCacheKey = "GeoFeedData"; public PreLoadGeoFeed(ILogger 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}");