fix: use full intervals content in worker cache key, not just length
Two different interval sets with the same length would produce the same cache key, returning stale results. Serialize each interval's startedAt~completedAt into the key.
This commit is contained in:
parent
270eb547cb
commit
bc7981f6b9
1 changed files with 4 additions and 1 deletions
|
|
@ -44,7 +44,10 @@ parentPort?.on('message', async (msg: TeamDataWorkerRequest) => {
|
|||
}
|
||||
case 'findLogsForTask': {
|
||||
const { teamName, taskId, options } = msg.payload;
|
||||
const cacheKey = `${teamName}:${taskId}:${options?.owner ?? ''}:${options?.status ?? ''}:${options?.since ?? ''}:${options?.intervals?.length ?? 0}`;
|
||||
const intervalsKey = options?.intervals
|
||||
? options.intervals.map((i) => `${i.startedAt}~${i.completedAt ?? ''}`).join(',')
|
||||
: '';
|
||||
const cacheKey = `${teamName}:${taskId}:${options?.owner ?? ''}:${options?.status ?? ''}:${options?.since ?? ''}:${intervalsKey}`;
|
||||
|
||||
// Check result cache
|
||||
const cached = logsResultCache.get(cacheKey);
|
||||
|
|
|
|||
Loading…
Reference in a new issue