feat(FN-4924): complete Step 1 — add tasks TTL constant

Fusion-Task-Id: FN-4924
Fusion-Task-Lineage: a5f882e1-8348-4f9d-89be-15994adc148c
This commit is contained in:
Fusion (runfusion.ai)
2026-05-17 12:30:27 -07:00
committed by gsxdsm
parent f3f4a0b46b
commit 13bcb8ed85
2 changed files with 8 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import {
SWR_CACHE_KEYS, SWR_CACHE_KEYS,
SWR_DEFAULT_MAX_AGE_MS, SWR_DEFAULT_MAX_AGE_MS,
SWR_LONG_MAX_AGE_MS, SWR_LONG_MAX_AGE_MS,
SWR_TASKS_MAX_AGE_MS,
clearCache, clearCache,
readCache, readCache,
writeCache, writeCache,
@@ -123,6 +124,7 @@ describe("swrCache", () => {
expect(SWR_CACHE_KEYS.MAILBOX_OUTBOX_PREFIX).toBe("kb-dashboard-mailbox-outbox-cache:"); expect(SWR_CACHE_KEYS.MAILBOX_OUTBOX_PREFIX).toBe("kb-dashboard-mailbox-outbox-cache:");
expect(SWR_CACHE_KEYS.MAILBOX_UNREAD_COUNT_PREFIX).toBe("kb-dashboard-mailbox-unread-cache:"); expect(SWR_CACHE_KEYS.MAILBOX_UNREAD_COUNT_PREFIX).toBe("kb-dashboard-mailbox-unread-cache:");
expect(SWR_DEFAULT_MAX_AGE_MS).toBe(10 * 60 * 1000); expect(SWR_DEFAULT_MAX_AGE_MS).toBe(10 * 60 * 1000);
expect(SWR_TASKS_MAX_AGE_MS).toBe(60_000);
expect(SWR_LONG_MAX_AGE_MS).toBe(24 * 60 * 60 * 1000); expect(SWR_LONG_MAX_AGE_MS).toBe(24 * 60 * 60 * 1000);
}); });

View File

@@ -1,6 +1,9 @@
/** /**
* Lightweight stale-while-revalidate cache helpers for dashboard reload hydration. * Lightweight stale-while-revalidate cache helpers for dashboard reload hydration.
* *
* Board task hydration uses a dedicated soft bound (`SWR_TASKS_MAX_AGE_MS`) so reloads do not present obviously stale task snapshots.
* Failed task revalidation clears the per-project tasks envelope to avoid re-hydrating stale data on the next reload.
*
* Invalidation contract: * Invalidation contract:
* - Per-project task entries use `SWR_CACHE_KEYS.TASKS_PREFIX + projectId`. * - Per-project task entries use `SWR_CACHE_KEYS.TASKS_PREFIX + projectId`.
* - Version updates clear TASKS_PREFIX plus PROJECTS and CURRENT_PROJECT_ID. * - Version updates clear TASKS_PREFIX plus PROJECTS and CURRENT_PROJECT_ID.
@@ -35,7 +38,10 @@ interface CacheEnvelope<T> {
data: T; data: T;
} }
// Shared default for non-live dashboard hydration paths.
export const SWR_DEFAULT_MAX_AGE_MS = 10 * 60 * 1000; export const SWR_DEFAULT_MAX_AGE_MS = 10 * 60 * 1000;
// Board hydration soft bound: keep stale tasks visible briefly while forcing immediate revalidation.
export const SWR_TASKS_MAX_AGE_MS = 60_000;
export const SWR_LONG_MAX_AGE_MS = 24 * 60 * 60 * 1000; export const SWR_LONG_MAX_AGE_MS = 24 * 60 * 60 * 1000;
function getLocalStorage(): Storage | null { function getLocalStorage(): Storage | null {