jlongster / absurd-sql

sqlite3 in ur indexeddb (hopefully a better backend soon)
MIT License
4.18k stars 100 forks source link

Call for help: webkitFileSystem backed #12

Open jlongster opened 3 years ago

jlongster commented 3 years ago

I have already written a backend using webkitFileSystem: https://gist.github.com/jlongster/ec00ddbb47b4b29897ab5939b8e32fbe

I did it somewhat naively though. It's way slower because I don't know how to do bulk reads/writes. I can't find anything in the API about it, or any examples. Surely there's a way to avoid doing entry.file every single time??https://gist.github.com/jlongster/ec00ddbb47b4b29897ab5939b8e32fbe#file-webkitfilesystem-backend-js-L48

Sure you can somehow call writer.write more than once? When I tried it, it errored. Calling createWriter each time is super slow! https://gist.github.com/jlongster/ec00ddbb47b4b29897ab5939b8e32fbe#file-webkitfilesystem-backend-js-L36

I should probably create a PR so that you already have some running code with it. I'd love for someone to help with it!

beeing commented 3 years ago

Hi @jlongster, how about cache the entry using WeakMap? Or perhaps with TTL or idleTimeout.

For repeat writes, have you tried to re-seek after writing?

I can try it out when I have some time.

jlongster commented 3 years ago

It's already cached in openFile: https://gist.github.com/jlongster/ec00ddbb47b4b29897ab5939b8e32fbe#file-webkitfilesystem-backend-js-L8

I'm going to open a PR with initial implementation though. It's using the sync API which is a lot simpler. Wait until then to start working on it! The code is a lot different

jlongster commented 3 years ago

Just opened a PR: https://github.com/jlongster/absurd-sql/pull/13