diff --git a/AS1024.GeoFeed/Controllers/GeofeedController.cs b/AS1024.GeoFeed/Controllers/GeofeedController.cs index 3bb973d..9e5ec53 100644 --- a/AS1024.GeoFeed/Controllers/GeofeedController.cs +++ b/AS1024.GeoFeed/Controllers/GeofeedController.cs @@ -15,24 +15,31 @@ namespace AS1024.GeoFeed.Controllers { private readonly IGeoFeedProvider builder; private readonly IMemoryCache memoryCache; + private readonly IWebHostEnvironment environment; private const string GeoFeedCacheKey = "GeoFeedData"; public GeofeedController(IGeoFeedProvider builder, - IMemoryCache memoryCache) { + IMemoryCache memoryCache, + IWebHostEnvironment environment) { this.builder = builder; this.memoryCache = memoryCache; + this.environment = environment; } [HttpGet] [Route("")] public async Task Get() { - if (!memoryCache.TryGetValue(GeoFeedCacheKey, out List? feed)) + if (!memoryCache.TryGetValue(GeoFeedCacheKey, out List? feed) + && environment.IsProduction()) { feed = await builder.GetGeoFeedData(); var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromMinutes(15)); memoryCache.Set(GeoFeedCacheKey, feed, cacheEntryOptions); + } else + { + feed = await builder.GetGeoFeedData(); } var csvContent = feed.ToGeoFeedCsv(); // Assuming ToGeoFeedCsv() returns a string in CSV format.