kvstore

Simple Key-Value Store

Functions

FunctionDescription
_kv_byte_atInternal byte reader.
_kv_copyInternal: copy bytes.
_kv_eqInternal: compare two byte ranges.
_kv_findInternal: find key index, returns -1 if not found.
kv_newCreate a new key-value store.
kv_putInsert or update a key-value pair. Returns 1 on update, 0 on insert.
kv_getGet value for a key. Copies to out buffer. Returns length, or -1 if not found.
kv_delDelete a key. Returns 1 if found, 0 if not found.
kv_hasCheck if key exists. Returns 1 or 0.
kv_countReturn the number of active entries.
kv_keysCopy key data into out buffer. Returns number of keys written. For each key: …
kv_key_copyCopy key bytes to output buffer given index from kv_keys.

Details

_kv_byte_at

fn _kv_byte_at(buf: &i8, idx: i64) -> i64

Internal byte reader.

_kv_copy

fn _kv_copy(dst: &i8, doff: i64, src: &i8, soff: i64, len: i64) -> i64

Internal: copy bytes.

_kv_eq

fn _kv_eq(a: &i8, aoff: i64, alen: i64, b: &i8, boff: i64, blen: i64) -> i64

Internal: compare two byte ranges.

_kv_find

fn _kv_find(h: &i64, key: &i8, klen: i64) -> i64

Internal: find key index, returns -1 if not found.

kv_new

fn kv_new() -> &i64

Create a new key-value store.

kv_put

fn kv_put(h: &i64, key: &i8, klen: i64, val: &i8, vlen: i64) -> i64

Insert or update a key-value pair. Returns 1 on update, 0 on insert.

kv_get

fn kv_get(h: &i64, key: &i8, klen: i64, out: &i8) -> i64

Get value for a key. Copies to out buffer. Returns length, or -1 if not found.

kv_del

fn kv_del(h: &i64, key: &i8, klen: i64) -> i64

Delete a key. Returns 1 if found, 0 if not found.

kv_has

fn kv_has(h: &i64, key: &i8, klen: i64) -> i64

Check if key exists. Returns 1 or 0.

kv_count

fn kv_count(h: &i64) -> i64

Return the number of active entries.

kv_keys

fn kv_keys(h: &i64, out: &i64, max: i64) -> i64

Copy key data into out buffer. Returns number of keys written. For each key: writes offset into keys_buf and length. out[i2] = offset, out[i2+1] = length

kv_key_copy

fn kv_key_copy(h: &i64, koff: i64, klen: i64, out: &i8) -> i64

Copy key bytes to output buffer given index from kv_keys.