fix(centralui): bound FlowDebugService script cache (review 2026-10-21 07/M-2)
This commit is contained in:
@@ -107,6 +107,13 @@ public sealed class FlowDebugService : IFlowDebugService
|
||||
/// </summary>
|
||||
private readonly Dictionary<int, InstanceScripts> _scriptCache = new();
|
||||
|
||||
/// <summary>
|
||||
/// Ceiling on <see cref="_scriptCache"/> entries (review 2026-10-21 07/M-2). Only the most
|
||||
/// recently selected instance is ever read back, so a small bound loses nothing; reaching it
|
||||
/// drops the whole cache before the new entry goes in.
|
||||
/// </summary>
|
||||
internal const int ScriptCacheCapacity = 8;
|
||||
|
||||
/// <summary>One instance's flattened scripts: the unique name the site keys on, the raw resolved scripts, and the picker projection.</summary>
|
||||
private sealed record InstanceScripts(
|
||||
string UniqueName,
|
||||
@@ -484,6 +491,10 @@ public sealed class FlowDebugService : IFlowDebugService
|
||||
.ToList();
|
||||
|
||||
var loaded = new InstanceScripts(instance.UniqueName, scripts, options);
|
||||
if (_scriptCache.Count >= ScriptCacheCapacity && !_scriptCache.ContainsKey(instanceId))
|
||||
{
|
||||
_scriptCache.Clear();
|
||||
}
|
||||
_scriptCache[instanceId] = loaded;
|
||||
return loaded;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user