ivoleitao / stash

Key-value store abstraction with plain and cache driven semantics and a pluggable backend architecture.
MIT License
82 stars 16 forks source link

stash_sqlite: use NativeDatabase.createInBackground to create a store #67

Closed RomainFranceschini closed 7 months ago

RomainFranceschini commented 7 months ago

Is your feature request related to a problem? Please describe. As sqlite3 is a synchronous C library, accessing the database from the main isolate can cause blocking IO operations

Describe the solution you'd like drift can spawn a long-running isolate to run SQL statements using NativeDatabase.createInBackground instead of the default NativeDatabase constructor.

Describe alternatives you've considered None

Additional context https://drift.simonbinder.eu/docs/advanced-features/isolates/

ivoleitao commented 7 months ago

This seems ok, thank you for the PR. If all goes well I will release today or tomorrow

ivoleitao commented 7 months ago

After looking it to it further I will probably change this a bit once merged to do not affect existing users, i.e. I will make it an opt-in feature the outcome will be the same but with a slightly different API. I will update here once done

ivoleitao commented 7 months ago

Added two new methods:

You can use them to create a background isolate and thus achieve the same that you were proposing with your PR. It was released on the 5.1.0 version of stash_sqlite

RomainFranceschini commented 7 months ago

Great, thank you