diff --git a/docs/release-notes.md b/docs/release-notes.md index fc8adc61..f389ba25 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -11,6 +11,9 @@ * `Specialised.LoadStageChanged`. * You can now use `helper.Data.Read/WriteSaveData` as soon as the save is loaded (instead of once the world is initialised). +* For the web UI: + * Reduced mod compatibility list's cache time. + ## 2.9.3 * For players: * Fixed errors hovering items in some cases with SMAPI 2.9.2. 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; /// The number of minutes successful update checks should be cached before refetching them. - private readonly int SuccessCacheMinutes; + private readonly int CacheMinutes; /********* @@ -31,12 +31,12 @@ namespace StardewModdingAPI.Web.Controllers /// Construct an instance. /// The cache in which to store mod metadata. /// The config settings for mod update checks. - public ModsController(IMemoryCache cache, IOptions configProvider) + public ModsController(IMemoryCache cache, IOptions configProvider) { - ModUpdateCheckConfig config = configProvider.Value; + ModCompatibilityListConfig config = configProvider.Value; this.Cache = cache; - this.SuccessCacheMinutes = config.SuccessCacheMinutes; + this.CacheMinutes = config.CacheMinutes; } /// Display information for all mods. @@ -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 +{ + /// The config settings for mod compatibility list. + internal class ModCompatibilityListConfig + { + /********* + ** Accessors + *********/ + /// The number of minutes data from the wiki should be cached before refetching it. + 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(this.Configuration.GetSection("ModCompatibilityList")) .Configure(this.Configuration.GetSection("ModUpdateCheck")) .Configure(this.Configuration.GetSection("Site")) .Configure(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,