import { useCallback, useMemo, useRef } from "react"; export function useWorkspaceTabCache() { const cacheRef = useRef(new Map()); const getCached = useCallback((key: string) => cacheRef.current.get(key), []); const setCached = useCallback((key: string, value: T) => { cacheRef.current.set(key, value); }, []); const clearCached = useCallback((prefix?: string) => { if (!prefix) { cacheRef.current.clear(); return; } for (const key of Array.from(cacheRef.current.keys())) { if (key.startsWith(prefix)) { cacheRef.current.delete(key); } } }, []); return useMemo(() => ({ getCached, setCached, clearCached }), [getCached, setCached, clearCached]); }