Skip to content

docs: Phase 3 cacheTime single-runtime design#126

Merged
mahyarmlk merged 1 commit into
mainfrom
docs/cacheTime-phase3-design
Jun 27, 2026
Merged

docs: Phase 3 cacheTime single-runtime design#126
mahyarmlk merged 1 commit into
mainfrom
docs/cacheTime-phase3-design

Conversation

@mahyarmlk

Copy link
Copy Markdown
Collaborator

Summary

Refines the resource cache design for Phase 3: single-runtime cacheTime.

Changes

  • docs/proposals/Resource-Cache-And-Stale-Semantics.md
    • Updated status header to reflect Phase 3 design
    • Updated cacheTime proposed design section with new semantics (default undefined, single-runtime only, no cross-navigation)
    • Added detailed Phase 3 section: "Phase 3: CacheTime — Single-Runtime Design"
    • Added "Approved Phase 3 Implementation Slice" with design decisions (Q1-Q8)
    • Added comprehensive test plan (29 tests)
    • Added compatibility and migration notes
    • Updated Implementation Status table with Phase 3 decisions
    • Added footnote to interaction matrix clarifying cross-navigation row

Key Semantics

  • cacheTime is optional (ms), default undefined (no time-based eviction)
  • Starts when an entry becomes stale (invalidate, action, staleTime expiry)
  • Active entry eviction: status→idle, value→undefined, subscribers notified
  • Inactive entry eviction: removed from Map silently, no notification
  • Successful reload clears the cacheTime timer
  • Failed reload does NOT start cacheTime (preserves Phase 1/2 behavior)
  • Runtime dispose() clears all timers and entries
  • Per-key for keyed resources; works for non-keyed resources too

Validation

  • pnpm lint
  • pnpm typecheck
  • pnpm build
  • pnpm pack:check
  • pnpm changeset status ✓ (no packages to bump)

This is a docs-only change. No runtime code, no examples, no changesets.

@mahyarmlk mahyarmlk merged commit 409bb62 into main Jun 27, 2026
1 check passed
mahyarmlk added a commit that referenced this pull request Jun 27, 2026
#127)

* feat(core): resource cache phase 3 — cacheTime single-runtime eviction

* fix(core): two resource cache runtime edge cases

Fix 1 — in-flight promise after inactive eviction must not mutate
detached entries. Add ownership check (entries.get(key) !== entry)
before applying success/failure results, calling staleNotify(), or
starting staleTime/cacheTime timers.

Fix 2 — switching active key to an already in-flight entry must sync
public state (syncFromEntry) before dedupe early return. Previously
the dedupe path returned the in-flight promise without updating
currentStatus/currentValue/currentError, leaving public getters
showing the previous key's state.

Add tests:
- detached promise resolution does not notify subscribers
- detached promise resolution does not start timers
- switching to in-flight key syncs state before dedupe return

* docs: fix Phase 3 implementation PR reference (PR #126 → PR #127)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant