hash-anu/snkv has 80 GitHub stars and 3 forks. GitHot measured 0 stars in 24 hours and +1 in 7 days. Last checked 2026-11-15 13:36 UTC. Last push 2026-11-05.
What you can do
- ACID transactions and WAL mode (concurrent readers, single writer)
- Native TTL: per-key expiry, lazy eviction, bulk kvstore_purge_expired(). No background thread.
- Encryption: per-value XChaCha20-Poly1305 with Argon2id key derivation, transparent to all APIs
- Column families: logical namespaces within one database
Measured star growth
- in 24h
- 0
- in 7 days
- +1
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
SNKV — a lightweight key-value store focused on simplicity, security and performance file based database , written using sqlite's b-tree directly. Now supports vector HNSW , Join the discussion: https://discord.gg/Wwe9dFy3P
DataREADME.md
Original
SNKV
A simple, crash-safe embedded key-value store
SNKV is a lightweight, ACID-compliant embedded key-value store written in C. It talks directly to SQLite's B-tree storage engine and skips the SQL layer: no parser, no query planner, no VM.
SQLite: Application → SQL Parser → Query Planner → VDBE → B-Tree → Disk
SNKV: Application → KV API → B-Tree → Disk
Looking for Python? The Python bindings are no longer maintained on
master. Use thepython_bindingsbranch.
Quick Start
Single-header integration:
#define SNKV_IMPLEMENTATION
#include "snkv.h"
int main(void) {
KVStore *db;
kvstore_open("mydb.db", &db, KVSTORE_JOURNAL_WAL);
kvstore_put(db, "key", 3, "value", 5);
void *val; int len;
kvstore_get(db, "key", 3, &val, &len);
printf("%.*s\n", len, (char*)val);
snkv_free(val);
kvstore_close(db);
}
- API reference: hash-anu.github.io/snkv/api.html
- Examples: examples/ · hash-anu.github.io/snkv/examples.html
Features
- ACID transactions and WAL mode (concurrent readers, single writer)
- Native TTL: per-key expiry, lazy eviction, bulk
kvstore_purge_expired(). No background thread. - Encryption: per-value XChaCha20-Poly1305 with Argon2id key derivation, transparent to all APIs
- Column families: logical namespaces within one database
- Iterators: forward and reverse, prefix, and seek
- Vector search: HNSW index via usearch (
make vector), stored in the same.dbfile. See examples/vector.c. - Thread-safe: share one handle (one lock per handle; a transaction stays with the thread that began it), or give each thread its own handle for parallel reads in WAL
- Single-header, Valgrind-clean
- Compatible with SQLite page/WAL-level tools such as LiteFS. Tools that need SQLite's schema layer (the
sqlite3CLI) do not work.
/* TTL */
kvstore_put_ttl(db, "session", 7, "tok123", 6, kvstore_now_ms() + 60000);
/* Encryption */
kvstore_open_encrypted("secure.db", "hunter2", 7, &db, NULL);
/* Custom configuration */
KVStoreConfig cfg = {0}; /* zero fields are NOT defaults: set journalMode */
cfg.journalMode = KVSTORE_JOURNAL_WAL;
cfg.syncLevel = KVSTORE_SYNC_FULL;
cfg.busyTimeout = 5000;
kvstore_open_v2("mydb.db", &db, &cfg);
Build
Linux / macOS
make # libsnkv.a
make snkv.h # single-header version
make examples # build examples
make test # run test suite
make vector # libsnkv_vec.a (core + usearch, requires g++)
make test-vector # run vector tests
Windows: use the MSYS2 MinGW 64-bit shell (not cmd.exe or PowerShell):
pacman -S --needed mingw-w64-x86_64-gcc make
make && make test
Benchmarks
1M records, mean of 5 runs on Linux (WSL2, tmpfs — measures engine CPU cost, not disk). Both stores use the same SQLite 3.51.2 core built with gcc -O2, WAL with auto-checkpoint every 1000 pages, synchronous=NORMAL, an 8 MB cache and 4 KB pages; SQLite uses a WITHOUT ROWID table and prepared statements.
Source: SNKV · SQLite · details in docs/benchmark.html
| Benchmark | SQLite | SNKV | Speedup |
|---|---|---|---|
| Sequential writes | 1.30M ops/s | 1.51M ops/s | 1.16x |
| Random reads | 254K ops/s | 588K ops/s | 2.32x |
| Sequential scan | 11.1M ops/s | 13.5M ops/s | 1.22x |
| Random updates | 108K ops/s | 120K ops/s | 1.11x |
| Random deletes | 124K ops/s | 126K ops/s | 1.01x |
| Exists checks | 262K ops/s | 653K ops/s | 2.49x |
| Mixed workload | 254K ops/s | 317K ops/s | 1.25x |
| Bulk insert | 1.50M ops/s | 1.75M ops/s | 1.17x |
Comparisons against LMDB and RocksDB are available too.
Good fit: read-heavy or mixed workloads (point reads and existence checks run about 2.3–2.5x faster than SQLite), native TTL (sessions, caches, leases), embedded or memory-constrained targets, and simple C integration. Consider alternatives: RocksDB for maximum write throughput, LMDB for maximum read speed when memory is plentiful.
Third-Party Licenses
| Library | License | Use |
|---|---|---|
| SQLite | Public Domain | B-tree, pager, WAL, OS layer (bundled) |
| Monocypher | CC0-1.0 | XChaCha20-Poly1305 + Argon2id (bundled) |
| usearch | Apache 2.0 | HNSW vector index (optional, make vector) |
License
Apache License 2.0 © 2025 Hash Anu