reduce cache time for failed update checks to 5 minutes (#454)
This commit is contained in:
parent
b5866c2c06
commit
ada351b163
|
@ -21,6 +21,7 @@
|
|||
* Fixed rare crash with some combinations of manifest fields and internal mod data.
|
||||
* Fixed update checks failing for Nexus Mods due to a change in their API.
|
||||
* Fixed update checks failing for some older mods with non-standard versions.
|
||||
* Fixed failed update checks being cached for an hour (now cached 5 minutes).
|
||||
* Fixed error when a content pack needs a mod that couldn't be loaded.
|
||||
* Fixed Linux ["magic number is wrong" errors](https://github.com/mono/mono/issues/6752) by changing default terminal order.
|
||||
* Updated compatibility list and added update checks for more mods.
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue