Append when the GeoFeed is retrieved and if it was generated from in memory cache

This commit is contained in:
2024-01-16 13:05:58 -08:00
parent 690a117ffd
commit c1ed05a335
3 changed files with 22 additions and 5 deletions

View File

@@ -55,10 +55,12 @@ namespace AS1024.GeoFeed.MinimalAPI
IMemoryCache memoryCache,
IWebHostEnvironment environment)
{
bool isCached = true;
try
{
if (!memoryCache.TryGetValue("Geofeed", out List<IPGeoFeed>? feed))
{
isCached = false;
feed = await provider.GetGeoFeedData();
if (environment.IsProduction())
{
@@ -68,7 +70,7 @@ namespace AS1024.GeoFeed.MinimalAPI
}
}
return Results.File(Encoding.UTF8.GetBytes(feed.ToGeoFeedCsv()),
return Results.File(Encoding.UTF8.GetBytes(feed.ToGeoFeedCsv(true, isCached)),
"text/csv",
"geofeed.csv");