multiSet method
Implementation
Future<void> multiSet(List<StorageKeyValue> keyValues) async {
var database = await _sqLiteHelper.getDatabase();
if (database == null) {
throw 'Database Error';
}
try {
// 事务的形式进行批量插入,性能问题待测试
await database.transaction((txn) async {
String sql;
for (var keyValue in keyValues) {
sql =
"INSERT OR REPLACE INTO ${_sqLiteHelper.getTableName()} VALUES ('${keyValue.key}','${keyValue.value}');";
await txn.execute(sql);
}
});
return;
} catch (e) {
LogUtils.e('flutterRender', e.toString());
} finally {
//todo 一些关闭操作
}
}