Skip to content

Instantly share code, notes, and snippets.

@zaiste
Created December 4, 2014 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaiste/47edd23368f63f8bd1c0 to your computer and use it in GitHub Desktop.
Save zaiste/47edd23368f63f8bd1c0 to your computer and use it in GitHub Desktop.
Using Redis in Go
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
)
func main() {
c, err := redis.Dial("tcp", ":6379")
if err != nil {
panic(err)
}
defer c.Close()
c.Do("SET", "foo", "This is foo")
c.Do("HSET", "bar", "1", "First bar")
val1, err := redis.String(c.Do("GET", "foo"))
if err != nil {
fmt.Println("key not found")
}
fmt.Println(val1)
val2, err := redis.String(c.Do("HGET", "bar", "1"))
if err != nil {
fmt.Println("key not found")
}
fmt.Println(val2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment