Add fetch_cached() client-side ORM cache with SPA auto-reset

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2026-02-20 19:58:32 +00:00
parent b5eb27a827
commit f58aa994ed
4 changed files with 173 additions and 53 deletions

View File

@@ -826,6 +826,8 @@ const tasks = await project.tasks(); // hasMany → Model[]
**fetch() is for SECURITY, not aliasing**: The `fetch()` method exists to remove private data users shouldn't see. NEVER alias enum properties (e.g., `type_label` instead of `type_id__label`) or format dates server-side. Use the full BEM-style names and format dates on client with `Rsx_Date`/`Rsx_Time`.
**Cached Fetch**: `Model.fetch_cached(id)` — in-memory cache for non-critical display data (names, labels, log history). Cache stores promises so concurrent calls share one request. `fetch()` and `fetch_or_null()` warm the cache. Resets automatically on SPA navigation. Manual reset: `Rsx_Js_Model.orm_cache_reset()`, `Rsx_Js_Model.orm_cache_reset('Model_Name')`, `Rsx_Js_Model.orm_cache_reset('Model_Name', id)`. Do NOT use for data that must be fresh after edits.
Details: `php artisan rsx:man model_fetch`
### Migrations