MCPcopy Create free account
hub / github.com/RioArisk/claudecode_api_RemoteControl / openChatCacheDb

Function openChatCacheDb

app/src/modules/chat-cache.js:11–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9let chatCacheDbPromise = null;
10
11export function openChatCacheDb() {
12 if (chatCacheDbPromise) return chatCacheDbPromise;
13 chatCacheDbPromise = new Promise((resolve, reject) => {
14 if (typeof indexedDB === 'undefined') {
15 reject(new Error('IndexedDB unavailable'));
16 return;
17 }
18 const req = indexedDB.open(CHAT_CACHE_DB, 1);
19 req.onerror = () => reject(req.error || new Error('Failed to open chat cache'));
20 req.onupgradeneeded = () => {
21 const db = req.result;
22 if (!db.objectStoreNames.contains(CHAT_CACHE_STORE)) {
23 const store = db.createObjectStore(CHAT_CACHE_STORE, { keyPath: 'cacheKey' });
24 store.createIndex('updatedAt', 'updatedAt', { unique: false });
25 }
26 };
27 req.onsuccess = () => resolve(req.result);
28 }).catch(err => {
29 console.warn('[chat-cache]', err);
30 chatCacheDbPromise = null;
31 throw err;
32 });
33 return chatCacheDbPromise;
34}
35
36export async function chatCacheRead(cacheKey) {
37 const db = await openChatCacheDb();

Callers 4

chatCacheReadFunction · 0.70
chatCacheWriteFunction · 0.70
chatCacheDeleteFunction · 0.70
chatCacheReadAllFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected