API Reference

go-redis

Redis client for Go with a context-aware API, pipelining, clustering, and pub/sub.

Official Documentation ↗
CompatibilityThis documentation covers version v9.6. Check the official docs for the latest API surface.

Installation

gogo get github.com/redis/go-redis/v9

Methods

go-redis is a Redis client for Go. It offers a context-aware API, connection pooling, pipelining, transactions, pub/sub, Lua scripting, and cluster support with automatic routing.

Key Features

  • Context-aware: Per-command deadlines and cancellation
  • Pipelining & transactions: Batch for speed or atomicity
  • Cluster: Automatic slot routing and failover
  • Pub/sub: Channel-based messaging
  • Types: Strings, hashes, lists, sets, sorted sets

Errors

The official API reference declares the following error types:

API reference evidence

Fetched from official sources on 2026-11-08T15:52:26+08:00 via WebFetch pkg.go.dev + PowerShell Invoke-WebRequest raw.githubusercontent.com (redis/go-redis v9.5.1).

FAQ

How do I connect to a Redis Cluster?
Use redis.NewClusterClient with a ClusterOptions containing the seed node addresses. The client handles slot routing, MOVED and ASK redirections, and failover automatically across the cluster.
What is the difference between Pipelined and TxPipeline?
Pipelined batches commands in one round trip without atomicity. TxPipeline wraps them in MULTI/EXEC for a transaction. Use TxPipeline when you need all commands to execute atomically.
How does go-redis handle context and timeouts?
Every command takes a context.Context, so you can enforce per-command deadlines and cancellation. Combine with Options.ReadTimeout and WriteTimeout for socket-level limits. Canceled contexts abort pending commands.