TF-624 Handling asynchronous when clearing cache

This commit is contained in:
dab246
2022-06-09 15:41:47 +07:00
committed by Dat H. Pham
parent d463dbed47
commit 34f3cfd6b1
6 changed files with 78 additions and 64 deletions
@@ -60,7 +60,7 @@ class MailboxCacheClient extends HiveCacheClient<MailboxCache> {
Future<void> insertItem(String key, MailboxCache newObject) {
return Future.sync(() async {
final boxMailbox = await openBox();
boxMailbox.put(key, newObject);
return boxMailbox.put(key, newObject);
}).catchError((error) {
throw error;
});
@@ -70,7 +70,7 @@ class MailboxCacheClient extends HiveCacheClient<MailboxCache> {
Future<void> insertMultipleItem(Map<String, MailboxCache> mapObject) {
return Future.sync(() async {
final boxMailbox = await openBox();
boxMailbox.putAll(mapObject);
return boxMailbox.putAll(mapObject);
}).catchError((error) {
throw error;
});
@@ -80,7 +80,7 @@ class MailboxCacheClient extends HiveCacheClient<MailboxCache> {
Future<void> updateItem(String key, MailboxCache newObject) {
return Future.sync(() async {
final boxMailbox = await openBox();
boxMailbox.put(key, newObject);
return boxMailbox.put(key, newObject);
}).catchError((error) {
throw error;
});
@@ -89,7 +89,7 @@ class MailboxCacheClient extends HiveCacheClient<MailboxCache> {
@override
Future<bool> isExistTable() {
return Future.sync(() async {
return await Hive.boxExists(tableName);
return Hive.boxExists(tableName);
}).catchError((error) {
throw error;
});
@@ -109,7 +109,7 @@ class MailboxCacheClient extends HiveCacheClient<MailboxCache> {
Future<void> updateMultipleItem(Map<String, MailboxCache> mapObject) {
return Future.sync(() async {
final boxMailbox = await openBox();
boxMailbox.putAll(mapObject);
return boxMailbox.putAll(mapObject);
}).catchError((error) {
throw error;
});
@@ -119,7 +119,7 @@ class MailboxCacheClient extends HiveCacheClient<MailboxCache> {
Future<void> clearAllData() {
return Future.sync(() async {
final boxMailbox = await openBox();
boxMailbox.clear();
return boxMailbox.clear();
}).catchError((error) {
throw error;
});