Query JSON like MongoDB but with Typesafe. Talk RESP like Redis. Embed as a Go library.
The problem
You need fast data access in your Go service. Your options:
- Redis — great protocol, but it stores strings. No JSON queries.
And it's another process to run, monitor, and pay latency tax on.
- MongoDB — rich queries, but heavy. Overkill for an embedded need.
- BoltDB / Badger — fast KV, but you're back to manual indexing
and stringly-typed everything.
redisx combines the best of all three into a single Go module you
go get and forget about.
30 seconds
db := server.Start()
defer server.Stop()
db.Set("user:1", `{"id":"1","name":"ken","age":18}`)
db.Set("user:2", `{"id":"2","name":"alice","age":25}`)
db.Get("user:1").MustGet()
// → {"id":"1","name":"ken","age":18}
One function call. Data on disk. Done. Now connect any Redis client
and keep going:
$ redis-cli -p 7379
> AUTH <your-key>
> GET user:1
{"id":"1","name":"ken","age":18}
> KEYS user:*
1) user:1
2) user:2
What else can it do?
- JSON queries — store JSON, query by field values, filter with
conditions like
age >= 18. No manual indexing, no string parsing.
- Typed documents — define a document type once. The library
auto-derives storage keys, index names, and routing. Works with both
the embedded DB and the remote Go client.
- Write hooks — intercept every write for data-loss prevention,
encryption, change capture, or cache invalidation. Register once,
applies everywhere. Zero call-site changes.
- Pub/Sub — publish and subscribe to topics, with pattern matching.
- Memory + disk — hot data in memory, durable data on disk. Routing
is automatic, based on a simple key prefix.
- Stream ingestion — pipe websocket feeds straight into your
document store, with auto-reconnect.
How does it compare?
|
Redis |
MongoDB |
redisx |
| Embed in your Go binary |
✗ |
✗ |
✓ |
| Query JSON by field values |
✗ |
✓ |
✓ |
| Use any Redis client |
✓ |
✗ |
✓ |
| Secondary indexes |
✗ |
✓ |
✓ |
| Type-safe Go API |
✗ |
✗ |
✓ |
| Write hooks (DLP, CDC, …) |
✗ |
✗ |
✓ |
| Runs without a separate server |
✓ |
✓ |
✓ |
Install
go get github.com/kcmvp/redisx
Next steps
License
MIT