ToriiDB is a four-in-one embedded Go database — Redis-style commands, MongoDB-style JSON queries, and OpenAI-powered semantic search, all persisted by an append-only log behind a single import.
go get github.com/agenvoy/toriidb
Cache, documents, and vectors behind a single command surface — a single Go import with no external services.
Redis-style KV commands, MongoDB-style field predicates, and semantic search behind one API — cache, document lookup, and similarity retrieval together.
SET ... VECTOR attaches an OpenAI embedding directly to the key — no sidecar store. The vector rides AOF and compaction alongside the value.
Embeddings cache under __torii:embed:<sha256>. Identical text never hits the OpenAI API twice — even across restarts.
VSEARCH linear-scans with a min-heap, filters by glob MATCH, honours LIMIT, and skips expired or dimension-mismatched entries.
Redis-compatible DB 0-15 namespaces, each with its own memory and AOF. Replay happens only on first access — startup stays free.
AOF appends every write in order, while each key also lands as a JSON snapshot under an MD5 three-level directory for external tooling.
GET / SET / DEL / INCR operate on nested fields via dot-notation — no read-modify-write round trips.
QUERY supports AND / OR / NOT with parentheses, exposed both as composable structs and as string expressions for untrusted input.
Scan commands skip the __torii:* prefix, so internal keys like the embedding cache never leak into KEYS, FIND, QUERY, or VSEARCH.
Every mutation flows through a single Exec router, then fans out to memory, the append log, and a JSON snapshot — no side doors.
Parse the command and route it through the single uppercase command switch.
exec.go →Apply to the per-DB in-memory map and warm the parsed JSON cache.
map[string]*Entry →Append the record — with optional base64 vector — to the per-DB log.
record.aof →Mirror the key as a JSON file under an MD5 three-level directory tree.
md5 snapshotVectors for meaning, predicates for exact fields. Both run over the in-memory map and shard across goroutines past 1024 entries.
Attach an embedding with SET ... VECTOR, then VSEARCH runs a top-K cosine scan — reusing the cached query embedding and filtering by glob MATCH.
FIND scans by operator; QUERY composes AND / OR / NOT infix expressions over dot-notation fields, with auto-chunked parallel scanning under the hood.
Values are classified on write and reported by TYPE — no schema, no declarations.
Objects and arrays, validated on write
UTF-8 text fallback
Whole numbers via ParseInt
Decimals via ParseFloat
true / false literals
RFC3339 or YYYY-MM-DD
Redis-familiar verbs route through a single Exec switch — dot-notation keys turn any value op into a JSON field op.
Set, read, and expire values. A dot in the key (user:1.name) targets a nested JSON field.
Scan documents by predicate and search by meaning. FIND/QUERY take an optional LIMIT.
Personal-scale data needs a linear scan and a good cache — not a distributed cluster behind a network.
Add the module, launch the REPL, store a key, and search by meaning.
Add ToriiDB to your Go module. macOS, Linux, Windows.
go get github.com/agenvoy/toriidb
Boots a Store with 16 databases under ./temp.
make test
Auto-detected as JSON; query nested fields by dot-notation.
SET user:1 {"name":"Pardn"}
Set OPENAI_API_KEY, attach a vector, then VSEARCH.
VSEARCH retry strategy LIMIT 3
KV, documents, and vectors — embedded, persisted, and built for Agenvoy.