summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r--src/SMAPI.Web/Controllers/ModsApiController.cs12
-rw-r--r--src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs7
-rw-r--r--src/SMAPI.Web/appsettings.json3
3 files changed, 15 insertions, 7 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs
index c99c87fb..24517263 100644
--- a/src/SMAPI.Web/Controllers/ModsApiController.cs
+++ b/src/SMAPI.Web/Controllers/ModsApiController.cs
@@ -29,8 +29,11 @@ namespace StardewModdingAPI.Web.Controllers
/// <summary>The cache in which to store mod metadata.</summary>
private readonly IMemoryCache Cache;
- /// <summary>The number of minutes update checks should be cached before refetching them.</summary>
- private readonly int CacheMinutes;
+ /// <summary>The number of minutes successful update checks should be cached before refetching them.</summary>
+ private readonly int SuccessCacheMinutes;
+
+ /// <summary>The number of minutes failed update checks should be cached before refetching them.</summary>
+ private readonly int ErrorCacheMinutes;
/// <summary>A regex which matches SMAPI-style semantic version.</summary>
private readonly string VersionRegex;
@@ -50,7 +53,8 @@ namespace StardewModdingAPI.Web.Controllers
ModUpdateCheckConfig config = configProvider.Value;
this.Cache = cache;
- this.CacheMinutes = config.CacheMinutes;
+ this.SuccessCacheMinutes = config.SuccessCacheMinutes;
+ this.ErrorCacheMinutes = config.ErrorCacheMinutes;
this.VersionRegex = config.SemanticVersionRegex;
this.Repositories =
new IModRepository[]
@@ -121,7 +125,7 @@ namespace StardewModdingAPI.Web.Controllers
}
// cache & return
- entry.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(this.CacheMinutes);
+ entry.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(info.Error == null ? this.SuccessCacheMinutes : this.ErrorCacheMinutes);
return info;
});
}
diff --git a/src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs
index 58c3a100..fc3b7dc2 100644
--- a/src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs
+++ b/src/SMAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs
@@ -6,8 +6,11 @@ namespace StardewModdingAPI.Web.Framework.ConfigModels
/*********
** Accessors
*********/
- /// <summary>The number of minutes update checks should be cached before refetching them.</summary>
- public int CacheMinutes { get; set; }
+ /// <summary>The number of minutes successful update checks should be cached before refetching them.</summary>
+ public int SuccessCacheMinutes { get; set; }
+
+ /// <summary>The number of minutes failed update checks should be cached before refetching them.</summary>
+ public int ErrorCacheMinutes { get; set; }
/// <summary>A regex which matches SMAPI-style semantic version.</summary>
/// <remarks>Derived from SMAPI's SemanticVersion implementation.</remarks>
diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json
index bfe827fa..03ca31ed 100644
--- a/src/SMAPI.Web/appsettings.json
+++ b/src/SMAPI.Web/appsettings.json
@@ -40,7 +40,8 @@
},
"ModUpdateCheck": {
- "CacheMinutes": 60,
+ "SuccessCacheMinutes": 60,
+ "ErrorCacheMinutes": 5,
"SemanticVersionRegex": "^(?>(?<major>0|[1-9]\\d*))\\.(?>(?<minor>0|[1-9]\\d*))(?>(?:\\.(?<patch>0|[1-9]\\d*))?)(?:-(?<prerelease>(?>[a-z0-9]+[\\-\\.]?)+))?$",
"ChucklefishKey": "Chucklefish",