tailor 0.1.1+2 copy "tailor: ^0.1.1+2" to clipboard
tailor: ^0.1.1+2 copied to clipboard

discontinued
outdated

A lightning-fast, synchronous, key-value database written in pure Dart.

TailorDB #

Tailor is a lightning-speed persistent key-value store for Dart. Using a synchronous, convenient API and an innovative caching system, it is able to write 200,000 objects, read 2 million, and delete 2 million, all in a single second. It is up to 40x faster than the nearest competition.


Features and Performance #

  • You can use Tailor synchronously or asynchronously: the core methods (normally synchronous) are available in async form.
  • Hive is generally considered the fastest pure-Dart database. Here's how Tailor compares to Hive (Intel M3):
    • On writes (200k Objects):
      • Tailor: 338 ms
      • Hive: 12485 ms
    • On Reads (200k Objects):
      • Tailor: 30 ms
      • Hive: 26 ms
    • On Deletes (200k Objects):
      • Tailor: 35 ms
      • Hive: 7081 ms
  • Tailor has strong AES-GCM encryption built in. Just use var db = TailorDB(file: fileHere, encryption: true, passkey: keyHere) and pass a key. You can generate a key using the genKey() method.
  • Tailor uses a LinkedHashMap structure internally, so insertion order is preserved.

Usage #

Take a look at the example below and API reference to understand the basic usage. Tailor is essentially a persistent map, with Strings as the main data type. Keys are all String, and Values are String, List<String>, or Map<String,String>.

import 'package:tailor/tailor.dart';

void main() {
  var db = TailorDB(
      file: File(join(Directory.current.path, 'example', 'db.json')),
      encryption: true,
      passkey: '6hUzyvUiXsf652tPHXLW2K-Fx6ZHEU_r');
  db.clear();
  db.add(key: 'String', value: 'value');
  db.add(key: 'List', value: ['here', 'are', 'values']);
  db.add(key: 'Map', value: {'key1': 'value1', 'key2': 'value2'});
  print(Map.fromIterables(db.keys, db.values));
}

//Check out the persistent storage in the db.json file in the example folder!

Normal and Flutter Usage #

  • In the constructor, you may notice a file parameter. This is because Tailor requires a JSON file to write to.
  • Normally, you can just specify the path to where the db should be (File('pathtodb/db.json')). If that is inconvenient you can create it in the current directory (File(join(Directory.current.path, 'db.json')).
  • In Flutter, you will need the [path provider][https://pub.dev/packages/path_provider#-readme-tab-] library. Use it to get a library directory (var dir = await getLibraryDirectory()). Then, create a JSON file there (File(join(dir.current.path, 'db.json')).
  • Note: the above uses methods from the dart:io, path, and path provider libraries. Dart:io and path are bundled with this library; you don't need to import them separately. If you need to import only the core library (and not dart:io/path), use import 'package:tailor/tailor.dart' show TailorDB.

Bugs #

Please file feature requests and bugs at the issue tracker.

16
likes
0
pub points
0%
popularity

Publisher

verified publisherkishoredev.live

A lightning-fast, synchronous, key-value database written in pure Dart.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

meta, path, steel_crypt

More

Packages that depend on tailor