`title: IndexedDB 在 Web Worker 中的事务调度与吞吐优化``categories: Web 开发/前端/数据管理``keywords: IndexedDB,Web Worker,事务,并发,吞吐``description: 在 Web Worker 中调度 IndexedDB 读写,利用事务聚合与批处理提升吞吐并避免主线程阻塞。`Worker 调度self.onmessage = async (e) => { const { type, items } = e.data; if (type === 'bulkPut') { const db = await openDB('worker-db', 1); await bulkPut(db, items); postMessage({ ok: true }); } }; 事务聚合将大量写操作合并到单事务内,必要时分批(如每 1000 条)。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部
1.892332s