-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need a way to reload the database / detect that it was changed by an external process. #374
Comments
sembast regular io format is not cross-process safe. A safer solution would be to use sembast_sqlite and sqflite_common_ffi which provides the same behavior and interface but is cross process safe (i.e. a record saved in an application is visible right away in the other application) although listeners (onSnapshot) won't get notified. |
i tried now with sembast_sqlite and sqflite_common_ffi but |
Thanks for the report @danteCarvalho and sorry for the delay. Indeed the database was currently only checked upon writing so any read would return the previously known data until a write is made. I added in sembast 3.7.1 the helper Does this solve (partially) your issue? |
Oh, thanks for the update, i will try it and give some feedback. |
I have a flutter app and a windox/linux dart service that uses the same sembast database. The service starts when the OS boots and run every 30 minutes.
If they are both running, any change to the database may not be reflected on the other, it seems like a new value wont show to the other as it is already loaded in memory.
1 One way to do this is to reload the database before every read/write operation. Maybe with a boolean param 'forceReload' on the store.record and store.find methods or on the openDatabase method. (maybe put a warning to not use with a big database)
2 Or i can just close and open the database every read/write operation, but that seems ugly.
3 The database could reload by itself when it detects that it was changed by an external process
The text was updated successfully, but these errors were encountered: