orange 1.2.8+1 orange: ^1.2.8+1 copied to clipboard
orange database is super fast and esay modern key-value store. working everywhere.and no need build_runner
import 'package:orange/orange.dart';
import 'package:code_timer/code_timer.dart';
main() async {
await Orange.init();
// write
Orange.setInt('counter', 10);
Orange.setBool('repeat', true);
Orange.setDouble('decimal', 1.5);
Orange.setString('action', 'Start');
Orange.setList('list', ['a', 'b', 2]);
Orange.setMap(
'map', {'string': 'value', 'int': 1, 'double': 1.5, 'bool': true});
// read
print(Orange.getInt('counter'));
print(Orange.getBool('repeat'));
print(Orange.getDouble('decimal'));
print(Orange.getString('action'));
print(Orange.getList('list'));
print(Orange.getMap('map'));
// remove
Orange.remove('int');
// performance test(10000 time writes)
CodeTimer.start();
for (int i = 0; i < 10000; i++) {
Orange.setInt('int$i', 1);
}
CodeTimer.stop(label: 'write performance test');
// performance test(10000 time reads)
CodeTimer.start();
for (int i = 0; i < 10000; i++) {
Orange.getInt('int$i');
}
CodeTimer.stop(label: 'read performance test');
CodeTimer.start();
await Orange.isSavedToDisk();
CodeTimer.stop(label: 'all data saved to disk!');
}