kvsql 0.2.0 copy "kvsql: ^0.2.0" to clipboard
kvsql: ^0.2.0 copied to clipboard

outdated

A type safe key/value store backed by Sqlite. It has methods to handle high throughput updates.

Kvsql #

pub package

A type safe key/value store for Flutter backed by Sqlite. Powered by Sqlcool.

Usage #

Initialize #

import 'package:kvsql/kvsql.dart';

store = KvStore();
await store.onReady;

Initialize with an existing Sqlcool database:

import 'package:kvsql/kvsql.dart';
import 'package:sqlcool/sqlcool.dart';

final db = Db();
await db.init(path: "mydb.db", schema=[kvSchema()]);
store = KvStore(db: db);

Insert or update #

await store.put<String>("mykey", "myvalue");

Supported value types are: String, int, double, List<T>, Map<K, V>

Allowed types for lists and maps keys and values are String, int and double

Delete #

await store.delete("mykey");

Select #

Returns a typed value

final String myValue = await store.select<List<int>>("mykey");

Select sync #

Synchronously select a value.

final String myValue = store.selectSync<Map<String, int>>("mykey");

For this to work you need to initialize the store with the inMemory option that keeps an in memory copy of the store values.

store = KvStore(inMemory = true);

Push #

This method upserts a key/value using a queue: it can be safely called concurrently. Useful for high throughput updates.

 store.push("mykey", "my_value");

Limitations:

  • This method is executed asynchronously but can not be awaited
  • It does not control the type of the data

Note: if you don't await your mutations or use push you are exposed to eventual consistency

Check the examples for detailled usage.

0
likes
0
points
13
downloads

Publisher

unverified uploader

Weekly Downloads

A type safe key/value store backed by Sqlite. It has methods to handle high throughput updates.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter, path_provider, pedantic, sqlcool

More

Packages that depend on kvsql