(key: string, id: string, data: T)
| 102 | } |
| 103 | |
| 104 | function getCache<T>(key: string): Record<string, { data: T; timestamp: number }> { |
| 105 | try { const c = localStorage.getItem(key); return c ? JSON.parse(c) : {}; } catch { return {}; } |
| 106 | } |
| 107 | function setCache<T>(key: string, id: string, data: T) { |
| 108 | const cache = getCache<T>(key); |
| 109 | (cache as any)[id] = { data, timestamp: Date.now() }; |
| 110 | localStorage.setItem(key, JSON.stringify(cache)); |
| 111 | } |
no test coverage detected