IO-Design-Team / hive_ce

Hive Community Edition - A spiritual continuation of Hive v2
https://pub.dev/packages/hive_ce
Apache License 2.0
41 stars 3 forks source link

introduce the Hive.flush() method #48

Open wenyue opened 3 days ago

wenyue commented 3 days ago

Can we provide the flush api? This needs to be used in some cases.

Version

Rexios80 commented 3 days ago

Can you elaborate on what cases need this? Also what would this feature do exactly?

wenyue commented 3 days ago

For example, before exiting the program, we need to make sure that all the data has been written to the hard disk. We now have a Hive.close() method, but this method call will close all boxes. This needs to ensure that we do not hold a reference to box, it is very difficult to use.

wenyue commented 3 days ago

Or can you provide a way to get all the boxes?

Rexios80 commented 2 days ago

Isn't all data persisted immediately? Have you ever lost data because of this?

wenyue commented 2 days ago

Yes, the data is persisted immediately, but I need to make sure that the persistence is complete and not exited on persistence

Rexios80 commented 2 days ago

Persisting the data should take almost zero seconds. What would cause the app to quit during that time? Where would you call this method?

Rexios80 commented 2 days ago

Also you could store references to all the futures of write operations and await them. That would basically be what a flush method would be.