Skip to content
Go Other
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


godis - a Redis client for Go. It supports all Redis commands and common features such as pipelines and pubsub.

  1. Package docs
  2. Source code

Install godis

godis is available at Get it by running.

$ git clone git://

And now compile and install it with one command.

$ make install

Importing godis to your code can be done with import "godis". Thats it!

Use godis

Checking out the code include a few examples. Here is the code for the example/strings.go.

package main

import (

func main() {
    // new client on default port 6379, select db 0 and use no password
    c := godis.New("tcp:", 0, "") 

    // set the key "foo" to "Hello Redis"
    c.Set("foo", "Hello Redis")

    // retrieve the value of "foo". Returns an Elem obj
    elem, _ := c.Get("foo")

    // convert the obj to a string and print it 
    fmt.Println("foo: ", elem.String())

Build the examples.

$ make 

To run it we type.

$ ./string
foo: Hello Redis

In case your redis server isn't running the output looks like this.

$ ./string 
Connection error


Pipelines include support for MULTI/EXEC operations.

c := godis.NewPipeClient("tcp:", 0, "", true)

Create a PipeClient. Subsequent commands will be buffered. PipeClient acts as a regular client, but implements a few extra commands; Multi, Exec, Unwatch, Watch, Discard*. The latter three are still not implemented. Setting transaction to true wraps commands inside MULTI .. EXEC.

c.Set("foo", "bar")

Commands are still called as usual, but will return an empty Reply.

replies := c.Exec()

To execute the buffered commands we call c.Exec(). Exec handles both MULTI/EXEC pipelines and simply buffered piplines. It returns a slice of all the *Reply objects for every command we executed.

See example/transaction.go for a full example.


  • Add tests server commands.
  • Pipeline need more testing.


The work on this client started as I was hacking around on Michael Hoisie's original redis client for Go. Also the recent work done by Frank Müller on his client gave me some pointers how to better handle return values.

Something went wrong with that request. Please try again.