mirror of
https://github.com/RPCS3/discord-bot.git
synced 2025-03-01 06:05:34 +00:00
limit in-memory caching duration times
This commit is contained in:
parent
2ee0d9eebc
commit
e71e9cc8ce
@ -25,6 +25,7 @@ namespace PsnClient
|
||||
private readonly MediaTypeFormatterCollection underscoreFormatters;
|
||||
private readonly MediaTypeFormatterCollection xmlFormatters;
|
||||
private static readonly MemoryCache ResponseCache = new MemoryCache(new MemoryCacheOptions { ExpirationScanFrequency = TimeSpan.FromHours(1) });
|
||||
private static readonly TimeSpan ResponseCacheDuration = TimeSpan.FromHours(1);
|
||||
private static readonly Regex ContainerIdLink = new Regex(@"(?<id>STORE-(\w|\d)+-(\w|\d)+)");
|
||||
private static readonly string[] KnownStoreLocales =
|
||||
{
|
||||
@ -251,7 +252,7 @@ namespace PsnClient
|
||||
|
||||
await response.Content.LoadIntoBufferAsync().ConfigureAwait(false);
|
||||
patchInfo = await response.Content.ReadAsAsync<TitlePatch>(xmlFormatters, cancellationToken).ConfigureAwait(false);
|
||||
ResponseCache.Set(productId, patchInfo);
|
||||
ResponseCache.Set(productId, patchInfo, ResponseCacheDuration);
|
||||
return patchInfo ?? new TitlePatch { Tag = new TitlePatchTag { Packages = new TitlePatchPackage[0], }, };
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -279,7 +280,7 @@ namespace PsnClient
|
||||
|
||||
await response.Content.LoadIntoBufferAsync().ConfigureAwait(false);
|
||||
meta = await response.Content.ReadAsAsync<TitleMeta>(xmlFormatters, cancellationToken).ConfigureAwait(false);
|
||||
ResponseCache.Set(id, meta);
|
||||
ResponseCache.Set(id, meta, ResponseCacheDuration);
|
||||
return meta;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -199,7 +199,7 @@ namespace CompatBot.Database.Providers
|
||||
|
||||
Config.Log.Trace("Getting dominant color for " + url);
|
||||
result = ColorGetter.Analyze(memStream.ToArray(), defaultColor);
|
||||
ColorCache.Set(url, result);
|
||||
ColorCache.Set(url, result, TimeSpan.FromHours(1));
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@ -16,7 +16,7 @@ namespace CompatBot.EventHandlers
|
||||
internal static class EmpathySimulationHandler
|
||||
{
|
||||
private static readonly TCache MessageQueue = new TCache();
|
||||
private static readonly TimeSpan ThrottleDuration = TimeSpan.FromDays(1);
|
||||
private static readonly TimeSpan ThrottleDuration = TimeSpan.FromHours(1);
|
||||
private static readonly MemoryCache Throttling = new MemoryCache(new MemoryCacheOptions {ExpirationScanFrequency = TimeSpan.FromMinutes(30)});
|
||||
|
||||
public static async Task OnMessageCreated(MessageCreateEventArgs args)
|
||||
|
@ -87,7 +87,7 @@ namespace CompatBot.Utils.Extensions
|
||||
|
||||
result = await azureDevOpsClient.GetArtifactsInfoAsync(commit, latestBuild, cancellationToken).ConfigureAwait(false);
|
||||
if (result.Status == BuildStatus.Completed && (result.Result == BuildResult.Succeeded || result.Result == BuildResult.PartiallySucceeded))
|
||||
BuildInfoCache.Set(commit, result, TimeSpan.FromDays(1));
|
||||
BuildInfoCache.Set(commit, result, TimeSpan.FromHours(1));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ namespace CompatBot.Utils.Extensions
|
||||
|
||||
result = await azureDevOpsClient.GetArtifactsInfoAsync(commit, latestBuild, cancellationToken).ConfigureAwait(false);
|
||||
if (result.Status == BuildStatus.Completed && (result.Result == BuildResult.Succeeded || result.Result == BuildResult.PartiallySucceeded))
|
||||
BuildInfoCache.Set(commit, result, TimeSpan.FromDays(1));
|
||||
BuildInfoCache.Set(commit, result, TimeSpan.FromHours(1));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ namespace CompatBot.Utils
|
||||
?? Encoding.ASCII;
|
||||
private static readonly Encoding Utf8 = new UTF8Encoding(false);
|
||||
private static readonly MemoryCache FuzzyPairCache = new MemoryCache(new MemoryCacheOptions {ExpirationScanFrequency = TimeSpan.FromMinutes(10)});
|
||||
private static readonly TimeSpan CacheTime = TimeSpan.FromMinutes(30);
|
||||
private const char StrikeThroughChar = '\u0336'; // 0x0335 = short dash, 0x0336 = long dash, 0x0337 = short slash, 0x0338 = long slash
|
||||
public const char InvisibleSpacer = '\u206a';
|
||||
public const char Nbsp = '\u00a0';
|
||||
@ -359,7 +360,7 @@ namespace CompatBot.Utils
|
||||
StrB = strB,
|
||||
Coefficient = strA.ToCanonicalForm().GetScoreWithAcronym(strB.ToCanonicalForm()),
|
||||
};
|
||||
FuzzyPairCache.Set(cacheKey, match);
|
||||
FuzzyPairCache.Set(cacheKey, match, CacheTime);
|
||||
return match.Coefficient;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user