flutter_cache_manager icon indicating copy to clipboard operation
flutter_cache_manager copied to clipboard

feat: add hive

Open Gorniv opened this issue 5 years ago • 16 comments

Use hive(https://github.com/hivedb/hive) instead SQLite.

Gorniv avatar Oct 19 '19 13:10 Gorniv

@Gorniv Why use hive instead of SQLite?

petermichaux avatar Dec 13 '19 18:12 petermichaux

@petermichaux because its much faster than sqlite.

Nisthar avatar Dec 14 '19 06:12 Nisthar

cache manager uses SQLite only like key-value storage, but hive faster! And I have crashed at the android device with SQLite error.

Gorniv avatar Dec 14 '19 14:12 Gorniv

also i think hive have a simple api than sqlite. so it would be easy to implement.

Nisthar avatar Dec 15 '19 05:12 Nisthar

same problem here, sqlite causes this problem Warning database has been locked for 0:00:10.000000. Make sure you always use the transaction object for database operations during a transaction

ahmedkassem avatar Dec 15 '19 20:12 ahmedkassem

hivedb support web!

Gorniv avatar Jan 08 '20 11:01 Gorniv

This package is used to store files, something that cannot be done on web as dart:io isn't available so web support isn't a concern.

Maybe migrating to moor is viable? A dev version using moor_ffi would be awesome

britannio avatar May 17 '20 19:05 britannio

hivedb work in web. Read docs of hivedb

Gorniv avatar May 18 '20 06:05 Gorniv

hivedb work in web. Read docs of hivedb

I know, read my message again.

britannio avatar May 18 '20 06:05 britannio

sorry, I think you write about hive)

Gorniv avatar May 18 '20 09:05 Gorniv

If someone is interested in adding support, they would need to implement the CacheInfoRepository interface: https://github.com/Baseflow/flutter_cache_manager/blob/ed5a205bcb5e816d05113c0360fea02aadc7e2be/flutter_cache_manager/lib/src/storage/cache_info_repository.dart

venkatd avatar Jul 23 '20 18:07 venkatd

This one works well for me:

https://github.com/vishna/flutter_cache_manager_hive

joe-getcouragenow avatar Sep 02 '20 07:09 joe-getcouragenow

any update?

a0v0 avatar Jan 03 '23 02:01 a0v0

I don't think this is a Hive vs sqflite debate. flutter_cache_manager is a library, and it should have flexibility depending on what the developer needs to use in the rest of the project. The worst case is to dictate sqflite or hive when the developer is using the other one, and that means pulling in two dependencies, increases compile time, increases app size, increases app loading time, increases memory jank, increases garbage collection interruption, giving a worse user experience.

We don't want that. We want to have the flexibility, which is why interface pattern is so cherished by developers. We do have the cache_info_repository.dart like an interface, maybe this file should be pulled into a separate Dart package on its own, and refactor flutter_cache_manager into a sqflite implementation. This allows someone to make the Hive implementation. Then we are all good to choose whichever dependency we like.

yangsfang avatar Feb 03 '23 17:02 yangsfang