kvstore
Simple Key-Value Store
Functions
| Function | Description |
|---|---|
_kv_byte_at | Internal byte reader. |
_kv_copy | Internal: copy bytes. |
_kv_eq | Internal: compare two byte ranges. |
_kv_find | Internal: find key index, returns -1 if not found. |
kv_new | Create a new key-value store. |
kv_put | Insert or update a key-value pair. Returns 1 on update, 0 on insert. |
kv_get | Get value for a key. Copies to out buffer. Returns length, or -1 if not found. |
kv_del | Delete a key. Returns 1 if found, 0 if not found. |
kv_has | Check if key exists. Returns 1 or 0. |
kv_count | Return the number of active entries. |
kv_keys | Copy key data into out buffer. Returns number of keys written. For each key: … |
kv_key_copy | Copy key bytes to output buffer given index from kv_keys. |
Details
_kv_byte_at
fn _kv_byte_at(buf: &i8, idx: i64) -> i64Internal byte reader.
_kv_copy
fn _kv_copy(dst: &i8, doff: i64, src: &i8, soff: i64, len: i64) -> i64Internal: copy bytes.
_kv_eq
fn _kv_eq(a: &i8, aoff: i64, alen: i64, b: &i8, boff: i64, blen: i64) -> i64Internal: compare two byte ranges.
_kv_find
fn _kv_find(h: &i64, key: &i8, klen: i64) -> i64Internal: find key index, returns -1 if not found.
kv_new
fn kv_new() -> &i64Create a new key-value store.
kv_put
fn kv_put(h: &i64, key: &i8, klen: i64, val: &i8, vlen: i64) -> i64Insert 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) -> i64Get 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) -> i64Delete a key. Returns 1 if found, 0 if not found.
kv_has
fn kv_has(h: &i64, key: &i8, klen: i64) -> i64Check if key exists. Returns 1 or 0.
kv_count
fn kv_count(h: &i64) -> i64Return the number of active entries.
kv_keys
fn kv_keys(h: &i64, out: &i64, max: i64) -> i64Copy 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) -> i64Copy key bytes to output buffer given index from kv_keys.