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
+6 -6
View File
@@ -60,7 +60,7 @@ class StateCacheClient extends HiveCacheClient<StateCache> {
Future<void> insertItem(String key, StateCache newObject) {
return Future.sync(() async {
final boxState = await openBox();
boxState.put(key, newObject);
return boxState.put(key, newObject);
}).catchError((error) {
throw error;
});
@@ -70,7 +70,7 @@ class StateCacheClient extends HiveCacheClient<StateCache> {
Future<void> insertMultipleItem(Map<String, StateCache> mapObject) {
return Future.sync(() async {
final boxState = await openBox();
boxState.putAll(mapObject);
return boxState.putAll(mapObject);
}).catchError((error) {
throw error;
});
@@ -80,7 +80,7 @@ class StateCacheClient extends HiveCacheClient<StateCache> {
Future<void> updateItem(String key, StateCache newObject) {
return Future.sync(() async {
final boxState = await openBox();
boxState.put(key, newObject);
return boxState.put(key, newObject);
}).catchError((error) {
throw error;
});
@@ -99,7 +99,7 @@ class StateCacheClient extends HiveCacheClient<StateCache> {
Future<void> deleteMultipleItem(List<String> listKey) {
return Future.sync(() async {
final boxState = await openBox();
boxState.deleteAll(listKey);
return boxState.deleteAll(listKey);
}).catchError((error) {
throw error;
});
@@ -109,7 +109,7 @@ class StateCacheClient extends HiveCacheClient<StateCache> {
Future<void> updateMultipleItem(Map<String, StateCache> mapObject) {
return Future.sync(() async {
final boxState = await openBox();
boxState.putAll(mapObject);
return boxState.putAll(mapObject);
}).catchError((error) {
throw error;
});
@@ -119,7 +119,7 @@ class StateCacheClient extends HiveCacheClient<StateCache> {
Future<void> clearAllData() {
return Future.sync(() async {
final boxState = await openBox();
boxState.clear();
return boxState.clear();
}).catchError((error) {
throw error;
});