rocicorp / replicache

Realtime Sync for Any Backend Stack
https://doc.replicache.dev
1.05k stars 37 forks source link

feat: Track Replicache IndexedDB databases in another IndexedDB database for mutation recovery and db gc. #802

Closed grgbkr closed 2 years ago

grgbkr commented 2 years ago

Problem

We need to be able to find old Replicache IndexedDB databases (i.e. databases with previous schema versions or replicache format versions), so that we can recover mutations from them and also GC them.

Solution

Keep track of Replicache IndexedDB databases in a IndexedDB database.

Unfortunately Firefox does not implement IDBFactory.databases, or we would use that api.

IndexedDB is used over LocalStorage because LocalStorage's lack of concurrency control makes it very difficult to avoid write clobbering when updating a list or map.

vercel[bot] commented 2 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/rocicorp/replicache/37Z7auVsdMkULbGm1qFgBgHY3Pj8
✅ Preview: https://replicache-git-grgbkr-sdd-store-schema-versions-rocicorp.vercel.app

arv commented 2 years ago

I really like how you are using the kv.Store to handle this. Beautiful!