Hanzo
Hanzo Skills Reference

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

ItemValue
Modulegithub.com/hanzoai/kv-go/v9
Packageredis
Version9.18.0-beta.2
Go1.26+
Repogithub.com/hanzoai/kv-go
Branchmaster
LicenseBSD-2-Clause
ProtocolRESP2/RESP3

Installation

go get github.com/hanzoai/kv-go/v9

Quick 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

ModulePathPurpose
redisotelgithub.com/hanzoai/kv-go/extra/redisotel/v9OpenTelemetry tracing + metrics
redisprometheusgithub.com/hanzoai/kv-go/extra/redisprometheus/v9Prometheus collector
rediscmdgithub.com/hanzoai/kv-go/extra/rediscmd/v9Command string formatting

Build and test

go build ./...
go test ./...
make test  # runs via Docker
  • hanzo/go-sdk.md - Hanzo AI API client
  • hanzo/hanzo-cloud.md - Cloud infrastructure

How is this guide?

Last updated on

On this page