diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-03-16 20:28:16 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-03-16 20:28:16 -0400 |
commit | ada351b163d928b5c01787e3ac3ad25ee6fe1ce4 (patch) | |
tree | 2e2d3be433d95652a450be3e0c729374c244a740 /src/SMAPI.Web/Controllers | |
parent | b5866c2c06bb0d3a993091e507f4eabb4aeaf8e7 (diff) | |
download | SMAPI-ada351b163d928b5c01787e3ac3ad25ee6fe1ce4.tar.gz SMAPI-ada351b163d928b5c01787e3ac3ad25ee6fe1ce4.tar.bz2 SMAPI-ada351b163d928b5c01787e3ac3ad25ee6fe1ce4.zip |
reduce cache time for failed update checks to 5 minutes (#454)
Diffstat (limited to 'src/SMAPI.Web/Controllers')
-rw-r--r-- | src/SMAPI.Web/Controllers/ModsApiController.cs | 12 |
1 files changed, 8 insertions, 4 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; }); } |