Hanzo KV Go SDK
Go client library for Hanzo KV (Redis/Valkey compatible). Fork of `redis/go-redis` v9 with module path rewritten to `github.com/hanzoai/kv-go/v9`. The Go package name is `redis` -- import the modul...
Overview
Go client library for Hanzo KV (Redis/Valkey compatible). Fork of redis/go-redis v9 with module path rewritten to github.com/hanzoai/kv-go/v9. The Go package name is redis -- import the module but use redis.NewClient().
OSS Base
Fork of go-redis (redis/go-redis). Repo: hanzoai/kv-go, branch: master.
Quick reference
| Item | Value |
|---|---|
| Module | github.com/hanzoai/kv-go/v9 |
| Package | redis |
| Version | 9.18.0-beta.2 |
| Go | 1.26+ |
| Repo | github.com/hanzoai/kv-go |
| Branch | master |
| License | BSD-2-Clause |
| Protocol | RESP2/RESP3 |
Installation
go get github.com/hanzoai/kv-go/v9Quick start
package main
import (
"context"
"fmt"
"github.com/hanzoai/kv-go/v9"
)
func main() {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
DB: 0,
})
defer rdb.Close()
ctx := context.Background()
err := rdb.Set(ctx, "key", "value", 0).Err()
if err != nil {
panic(err)
}
val, err := rdb.Get(ctx, "key").Result()
if err != nil {
panic(err)
}
fmt.Println("key", val)
}Key features
- Full Redis command coverage (strings, hashes, lists, sets, sorted sets, streams, HyperLogLog, geo, bitmaps, JSON, search, time series, probabilistic)
- Automatic connection pooling
- Pub/Sub
- Pipelines and transactions
- Lua scripting
- Redis Sentinel and Cluster support
- Streaming credentials provider (OAuth, Entra ID)
- OpenTelemetry instrumentation (
extra/redisotel) - Prometheus metrics (
extra/redisprometheus) - Vector set commands
Client types
// Standalone
rdb := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
// Sentinel (HA)
rdb := redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: "mymaster",
SentinelAddrs: []string{"localhost:26379"},
})
// Cluster
rdb := redis.NewClusterClient(&redis.ClusterOptions{
Addrs: []string{"localhost:7000", "localhost:7001", "localhost:7002"},
})
// Universal (auto-detects standalone/sentinel/cluster)
rdb := redis.NewUniversalClient(&redis.UniversalOptions{
Addrs: []string{"localhost:6379"},
})Extra modules
| Module | Path | Purpose |
|---|---|---|
| redisotel | github.com/hanzoai/kv-go/extra/redisotel/v9 | OpenTelemetry tracing + metrics |
| redisprometheus | github.com/hanzoai/kv-go/extra/redisprometheus/v9 | Prometheus collector |
| rediscmd | github.com/hanzoai/kv-go/extra/rediscmd/v9 | Command string formatting |
Build and test
go build ./...
go test ./...
make test # runs via DockerRelated Skills
hanzo/go-sdk.md- Hanzo AI API clienthanzo/hanzo-cloud.md- Cloud infrastructure
How is this guide?
Last updated on
Hanzo KV
Hanzo KV is a Redis-compatible in-memory key-value store used as the caching, streaming, and message broker layer across the Hanzo ecosystem. C codebase built with CMake, ships as `ghcr.io/hanzoai/...
Hanzo Logs
Hanzo Logs is a horizontally-scalable, multi-tenant log aggregation system for Hanzo infrastructure. Fork of Grafana Loki. Written in Go. Indexes labels (not full text) for cost-effective log stora...