lokv 1.0.1
LoKV #
Overview #
LoKV is a platform-independent embedded key-value database that runs on desktops, mobile devices, web browsers, and any platform that has a Dart or JavaScript runtime.
Waring: This project is under active development, and API is subject to change without notice.
1.0.0 #
- Initial version, created by Stagehand
import 'package:lokv/lokv.dart';
Future<int> main() async {
// Create a LoKV Database called lrig.
var lokv = VolatileLoKV.create('lrig');
// You need open the database before using it.
// If the database does not exist, it will be created.
await lokv.open();
// Put a record into the database.
await lokv.put('Suzuko Homura', 'Ril');
// Put another one.
await lokv.put('Hanna Mikage', 'Nanashi');
// Get the record we just put into.
var value = await lokv.get('Suzuko Homura');
assert(value == 'Ril');
value = await lokv.get('Hanna Mikage');
assert(value == 'Nanashi');
// If a record does not exist, it will return `null`.
value = await lokv.get('Chinatsu Morikawa');
assert(value == null);
// Put a value to an existing key will overwrite the existing value.
await lokv.put('Suzuko Homura', 'Mel');
value = await lokv.get('Suzuko Homura');
assert(value == 'Mel');
// Delete a record
await lokv.delete('Hanna Mikage');
value = await lokv.get('Hanna Mikage');
assert(value == null);
// Closing the database makes the database unreadable and unwritable,
// but does not cause data loss.
await lokv.close();
// After reopening, we can see that the previous data still exists.
await lokv.open();
value = await lokv.get('Suzuko Homura');
assert(value == 'Mel');
// We can use a write batch to complete multiple write operations,
// these operations either succeed together or fail together.
await lokv.write(WriteBatch()
..put('Kiyoi Mizushima', 'Piruluk')
..delete('Suzuko Homura')
..put('Chinatsu Morikawa', 'Mel'));
// Similarly, we can use a read batch to complete multiple read operations.
var values = await lokv.read(ReadBatch()
..get('Chinatsu Morikawa')
..get('Suzuko Homura')
..get('Kiyoi Mizushima'));
assert(values[0] == 'Mel');
assert(values[1] == null);
assert(values[2] == 'Piruluk');
// Drop a database will lose all the data,
// and free up the space used by the database.
await lokv.drop();
// You can open the database again,
// but this database is not the original one but newly created.
await lokv.open();
// We can see that the record we put before is gone.
value = await lokv.get('Kiyoi Mizushima');
assert(value == null);
// Remember to drop it when you no longer use a database.
await lokv.drop();
return 0;
}
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
lokv: ^1.0.1
2. Install it
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter pub get
Alternatively, your editor might support pub get
or flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:lokv/lokv.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
0
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
80
|
Overall:
Weighted score of the above.
[more]
|
46
|
We analyzed this package on Dec 4, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.12.21
Platforms
Detected platforms: Flutter, web, other
No platform restriction found in primary library
package:lokv/lokv.dart
.
Maintenance issues and suggestions
Homepage URL doesn't exist. (-20 points)
At the time of the analysis the homepage
field https://github.com/WakasaKina/lokv
was unreachable.