lokv 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 46

LoKV #

Pub Build Status

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:

  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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
meta ^1.1.7 1.1.8
Dev dependencies
pedantic ^1.5.0
test ^1.6.2
webdriver ^2.1.0