felangel / hydrated_bloc

An extension to the bloc state management library which automatically persists and restores bloc states.
https://pub.dev/packages/hydrated_bloc
MIT License
191 stars 23 forks source link

Add support for HiveDB #27

Closed MichelMelhem closed 4 years ago

MichelMelhem commented 4 years ago

Hello, Actually i'm using Hydrated_bloc not as a cache for my app but more as adatabase. I have two problems with it : First, hydrated bloc use temporary temporary storage so it can be wiped at any time. Second this do not support any encryption. I would sugget to implement Hive db as a way to persist data for two reasons : First hive support encryption, Hive is very light and powerfull and it can work on mobile, web and even desktop.

If you decide to add hive support please take in consideration to not init Hive inside a tempdir like is the case actually, so i could use it as a dataabase and not as a cache. Thank you for your help, Michel M

Read 1000 entries Write 1000 entries
SharedPreferences is on par with Hive when it comes to read performance. SQLite performs much worse. Hive greatly outperforms SQLite and SharedPreferences when it comes to writing or deleting.
genert commented 4 years ago

Hydration is taking an object that exists in memory and populating it with domain data from database for example and that is not the job of this library.

If you are using this library as persisting data to database, you have made architectural error and should rethink what this library solves and what you are trying to solve.

Use it for what is was meant - caching. You have to implement database logic by yourself.

MichelMelhem commented 4 years ago

@genert Felangel said me that he could implement HiveDb to hydrated_bloc, he just ask me to open a feature request ^^

felangel commented 4 years ago

Hey @MichelMelhem 👋 Thanks for opening an issue!

I think there are two requests here: use HiveDB and allow for long-term persistence. It sounds like you're more interested in the latter so I can expose an optional storagePath parameter on the built-in HydratedBlocStorage.

Regarding using Hive it's more of an implementation detail and I will first do a performance comparison before deciding whether or not to incorporate it.