Migrate Hive box To IsolatedHive box
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -6,35 +6,39 @@ class MemoryAccountCacheClient implements AccountCacheClient {
|
||||
final Map<String, AccountCache> _cache = {};
|
||||
|
||||
@override
|
||||
Future<void> clearAllData() {
|
||||
Future<void> clearAllData({bool isolated = false}) {
|
||||
_cache.clear();
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clearAllDataContainKey(String nestedKey) {
|
||||
Future<void> clearAllDataContainKey(
|
||||
String nestedKey, {
|
||||
bool isolated = false,
|
||||
}) {
|
||||
_cache.removeWhere((key, value) => key == nestedKey);
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> closeBox() {
|
||||
Future<void> closeBox({bool isolated = false}) {
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteBox() {
|
||||
Future<void> deleteBox({bool isolated = false}) {
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteItem(String key) {
|
||||
Future<void> deleteItem(String key, {bool isolated = false}) {
|
||||
_cache.remove(key);
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteMultipleItem(List<String> listKey) {
|
||||
Future<void> deleteMultipleItem(List<String> listKey,
|
||||
{bool isolated = false}) {
|
||||
_cache.removeWhere((key, value) => listKey.contains(key));
|
||||
return Future.value();
|
||||
}
|
||||
@@ -43,52 +47,60 @@ class MemoryAccountCacheClient implements AccountCacheClient {
|
||||
bool get encryption => false;
|
||||
|
||||
@override
|
||||
Future<List<AccountCache>> getAll() {
|
||||
Future<List<AccountCache>> getAll({bool isolated = false}) {
|
||||
return Future.value(_cache.values.toList());
|
||||
}
|
||||
|
||||
@override
|
||||
Future<AccountCache?> getItem(String key) {
|
||||
Future<AccountCache?> getItem(String key, {bool isolated = false}) {
|
||||
return Future.value(_cache[key]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<AccountCache>> getListByNestedKey(String nestedKey) {
|
||||
Future<List<AccountCache>> getListByNestedKey(
|
||||
String nestedKey, {
|
||||
bool isolated = false,
|
||||
}) {
|
||||
return Future.value(
|
||||
_cache.values.where((account) => account.id == nestedKey).toList());
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<AccountCache>> getValuesByListKey(List<String> listKeys) {
|
||||
Future<List<AccountCache>> getValuesByListKey(
|
||||
List<String> listKeys, {
|
||||
bool isolated = false,
|
||||
}) {
|
||||
return Future.value(_cache.values
|
||||
.where((account) => listKeys.contains(account.id))
|
||||
.toList());
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> insertItem(String key, AccountCache newObject) {
|
||||
Future<void> insertItem(
|
||||
String key,
|
||||
AccountCache newObject, {
|
||||
bool isolated = false,
|
||||
}) {
|
||||
_cache[key] = newObject;
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> insertMultipleItem(Map<String, AccountCache> mapObject) {
|
||||
Future<void> insertMultipleItem(
|
||||
Map<String, AccountCache> mapObject, {
|
||||
bool isolated = false,
|
||||
}) {
|
||||
_cache.addAll(mapObject);
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> isExistItem(String key) {
|
||||
Future<bool> isExistItem(String key, {bool isolated = false}) {
|
||||
return Future.value(_cache.containsKey(key));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<IsolatedBox<AccountCache>> openBox() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<IsolatedBox<AccountCache>> openBoxEncryption() {
|
||||
Future<Box<AccountCache>> openBox() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@@ -96,14 +108,31 @@ class MemoryAccountCacheClient implements AccountCacheClient {
|
||||
String get tableName => 'AccountCache';
|
||||
|
||||
@override
|
||||
Future<void> updateItem(String key, AccountCache newObject) {
|
||||
Future<void> updateItem(
|
||||
String key,
|
||||
AccountCache newObject, {
|
||||
bool isolated = false,
|
||||
}) {
|
||||
_cache[key] = newObject;
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> updateMultipleItem(Map<String, AccountCache> mapObject) {
|
||||
Future<void> updateMultipleItem(
|
||||
Map<String, AccountCache> mapObject, {
|
||||
bool isolated = false,
|
||||
}) {
|
||||
_cache.addAll(mapObject);
|
||||
return Future.value();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<IsolatedBox<AccountCache>> openIsolatedBox() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, AccountCache>> getMapItems({bool isolated = true}) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user