Skip to content
A simple, powerful Redis client for Go
Branch: master
Clone or download
Pull request Compare This branch is 17 commits ahead, 9 commits behind monnand:master.
astaxie Merge pull request #7 from goqihoo/patch-1
Fix bug: can not parse certain error bug
Latest commit 1f1c6e6 Aug 24, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
redis-dump formatted Jun 2, 2012
redis-load formatted Jun 2, 2012 modified readme Jun 27, 2012
hmget_test.go rename package Jun 27, 2012
redis.go Fix bug: can not parse certain error bug Aug 24, 2016
redis_test.go rename package Jun 27, 2012


NOTE: This is a modified version of redis.go by hoise to support the latest version of go.

NOTE: This project was called redis.go and renamed to goredis because of this. (In short, we can no longer use package names end in .go.)

This package supports the latest release of Go.

goredis is a client for the redis key-value store.

Some features include:

  • Designed for Redis 1.3.x.
  • Support for all redis types - strings, lists, sets, sorted sets, and hashes
  • Very simple usage
  • Connection pooling ( with configurable size )
  • Support for concurrent access
  • Manages connections to the redis server, including dropped and timed out connections
  • Marshaling/Unmarshaling go types to hashes

This library is stable and is used in production environments. However, some commands have not been tested as thoroughly as others. If you find any bugs please file an issue!


go get


Most of the examples connect to a redis database running in the default port -- 6367.

Instantiating the client

//connects to the default port (6379)
var client goredis.Client 
//connects to port 8379, database 13
var client2 goredis.Client
client2.Addr = ""
client2.Db = 13


var client goredis.Client
client.Set("a", []byte("hello"))
val, _ := client.Get("a")


var client goredis.Client
vals := []string{"a", "b", "c", "d", "e"}
for _, v := range vals {
    client.Rpush("l", []byte(v))
dbvals,_ := client.Lrange("l", 0, 4)
for i, v := range dbvals {


sub := make(chan string, 1)
sub <- "foo"
messages := make(chan Message, 0)
go client.Subscribe(sub, nil, nil, nil, messages)

time.Sleep(10 * 1000 * 1000)
client.Publish("foo", []byte("bar"))

msg := <-messages
println("received from:", msg.Channel, " message:", string(msg.Message))


More examples coming soon. See redis_test.go for more usage examples.

(Known) Projects using this package

Commands not supported yet

  • SORT
You can’t perform that action at this time.