Go Redis

Golang Redis client for Redis Server and Redis Cluster

Introduction Getting started

All flavors

Out-of-the-box works with Redis Server, Redis Cluster, Redis Sentinel, and even Ring of Redis Servers.


go-redis provides types for most Redis commands so you can work with well-structured replies.


We support pipelines, transactions, publish/subscribe, Lua scripts, mocks, distributed locks, and more.

package main

import (

func main() {
	ctx := context.Background()

	rdb := redis.NewClient(&redis.Options{
		Addr:	  "localhost:6379",
		Password: "", // no password set
		DB:		  0,  // use default DB

	err := rdb.Set(ctx, "key", "value", 0).Err()
	if err != nil {

	val, err := rdb.Get(ctx, "key").Result()
	if err != nil {
	fmt.Println("key", val)

	val2, err := rdb.Get(ctx, "key2").Result()
	if err == redis.Nil {
		fmt.Println("key2 does not exist")
	} else if err != nil {
	} else {
		fmt.Println("key2", val2)
	// Output: key value
	// key2 does not exist