summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Web/Controllers/ModsController.cs10
-rw-r--r--src/SMAPI.Web/Framework/ConfigModels/ModCompatibilityListConfig.cs12
-rw-r--r--src/SMAPI.Web/Startup.cs1
-rw-r--r--src/SMAPI.Web/appsettings.json4
4 files changed, 22 insertions, 5 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsController.cs b/src/SMAPI.Web/Controllers/ModsController.cs
index 1ac0aff2..ca866a8d 100644
--- a/src/SMAPI.Web/Controllers/ModsController.cs
+++ b/src/SMAPI.Web/Controllers/ModsController.cs
@@ -22,7 +22,7 @@ namespace StardewModdingAPI.Web.Controllers
private readonly IMemoryCache Cache;
/// <summary>The number of minutes successful update checks should be cached before refetching them.</summary>
- private readonly int SuccessCacheMinutes;
+ private readonly int CacheMinutes;
/*********
@@ -31,12 +31,12 @@ namespace StardewModdingAPI.Web.Controllers
/// <summary>Construct an instance.</summary>
/// <param name="cache">The cache in which to store mod metadata.</param>
/// <param name="configProvider">The config settings for mod update checks.</param>
- public ModsController(IMemoryCache cache, IOptions<ModUpdateCheckConfig> configProvider)
+ public ModsController(IMemoryCache cache, IOptions<ModCompatibilityListConfig> configProvider)
{
- ModUpdateCheckConfig config = configProvider.Value;
+ ModCompatibilityListConfig config = configProvider.Value;
this.Cache = cache;
- this.SuccessCacheMinutes = config.SuccessCacheMinutes;
+ this.CacheMinutes = config.CacheMinutes;
}
/// <summary>Display information for all mods.</summary>
@@ -66,7 +66,7 @@ namespace StardewModdingAPI.Web.Controllers
.OrderBy(p => Regex.Replace(p.Name.ToLower(), "[^a-z0-9]", "")) // ignore case, spaces, and special characters when sorting
);
- entry.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(this.SuccessCacheMinutes);
+ entry.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(this.CacheMinutes);
return model;
});
}
diff --git a/src/SMAPI.Web/Framework/ConfigModels/ModCompatibilityListConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/ModCompatibilityListConfig.cs
new file mode 100644
index 00000000..d9ac9f02
--- /dev/null
+++ b/src/SMAPI.Web/Framework/ConfigModels/ModCompatibilityListConfig.cs
@@ -0,0 +1,12 @@
+namespace StardewModdingAPI.Web.Framework.ConfigModels
+{
+ /// <summary>The config settings for mod compatibility list.</summary>
+ internal class ModCompatibilityListConfig
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The number of minutes data from the wiki should be cached before refetching it.</summary>
+ public int CacheMinutes { get; set; }
+ }
+}
diff --git a/src/SMAPI.Web/Startup.cs b/src/SMAPI.Web/Startup.cs
index 4e3aaed3..91553513 100644
--- a/src/SMAPI.Web/Startup.cs
+++ b/src/SMAPI.Web/Startup.cs
@@ -50,6 +50,7 @@ namespace StardewModdingAPI.Web
{
// init configuration
services
+ .Configure<ModCompatibilityListConfig>(this.Configuration.GetSection("ModCompatibilityList"))
.Configure<ModUpdateCheckConfig>(this.Configuration.GetSection("ModUpdateCheck"))
.Configure<SiteConfig>(this.Configuration.GetSection("Site"))
.Configure<RouteOptions>(options => options.ConstraintMap.Add("semanticVersion", typeof(VersionConstraint)))
diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json
index 89505a45..e97b2339 100644
--- a/src/SMAPI.Web/appsettings.json
+++ b/src/SMAPI.Web/appsettings.json
@@ -47,6 +47,10 @@
"PastebinDevKey": null // see top note
},
+ "ModCompatibilityList": {
+ "WikiCacheMinutes": 10
+ },
+
"ModUpdateCheck": {
"SuccessCacheMinutes": 60,
"ErrorCacheMinutes": 5,