From 0bfcd9cd6740ae0d4bdebabd5bcdd441009cb9dc Mon Sep 17 00:00:00 2001 From: xiaosi <2652281683@qq.com> Date: Thu, 3 Sep 2026 15:52:27 +0800 Subject: [PATCH] docs: repair play-url cache spec code fence --- ...-09-03-live-playurl-session-cache-design.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/docs/superpowers/specs/2026-09-03-live-playurl-session-cache-design.md b/docs/superpowers/specs/2026-09-03-live-playurl-session-cache-design.md index 92e879f..5340cf3 100644 --- a/docs/superpowers/specs/2026-09-03-live-playurl-session-cache-design.md +++ b/docs/superpowers/specs/2026-09-03-live-playurl-session-cache-design.md @@ -39,19 +39,12 @@ 伪代码(两页各自落地,字段名可本地化): ```js +const PLAY_URL_FRESH_MS = 30_000 + let playUrlPromise = null let playUrlSessionId = '' async function ensurePlayUrl(sessionId, { force = false } = {}) { - if ( - !force && - activeSessionId === sessionId && - playUrl && - playUrlExpiresAt * 1000 - Date.now() > 30_000 - ) { - return { playUrl, expiresAt: playUrlExpiresAt } // 或直接 true / 沿用现有写入形态 - } - if ( !force && activeSessionId === sessionId && @@ -68,7 +61,8 @@ async function ensurePlayUrl(sessionId, { force = false } = {}) { playUrlSessionId = sessionId playUrlPromise = getLivePlayURL(dockId, sessionId) .then((play) => { - if (activeSessionId !== sessionId) return play // 调用方仍须再校验后再写入本地状态 + // 回写前调用方仍须再校验 session;此处仅作提示性守卫 + if (activeSessionId !== sessionId) return play return play }) .finally(() => { @@ -76,10 +70,10 @@ async function ensurePlayUrl(sessionId, { force = false } = {}) { }) return playUrlPromise -常量:`PLAY_URL_FRESH_MS = 30_000`(与现有临期续期 lead 对齐)。**写入** `playUrl` / `expiresAt` / `schedulePlayRefresh` 由调用方在 ensure resolve 且 session 仍匹配后执行(Monitor 可把写入收进 ensure 内部,但必须含二次 session 校验)。 +} ``` -常量:`PLAY_URL_FRESH_MS = 30_000`(与现有临期续期 lead 对齐)。 +常量:`PLAY_URL_FRESH_MS = 30_000`(与现有临期续期 lead 对齐)。**写入** `playUrl` / `expiresAt` / `schedulePlayRefresh` 由调用方在 ensure resolve 且 session 仍匹配后执行(Monitor 可把写入收进 ensure 内部,但必须含二次 session 校验)。 ### 4.2 Monitor:`useMonitorLive.js`