Help us shape the future of Go! Take the 2026 Go Developer Survey

go_redis_client

module
v0.0.0-...-2618ffd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2016 License: MIT

README

go_redis_client

Golang Build Status Coverage Status Go Report Card license GoDoc

go_redis_client is a redis client for Go, which designed to be a successor of redigo 👍

Warning

go_redis_client is under heavy development, if you want to use it in your project, vendor it!

Benchmark

redis_go_client include a benchmark against redigo

Benchmark with redigo

How to

Single command
    opt := redis.Option{
        Auth: "password",
    }
    conn, err := redis.Connect("127.0.0.1", "6379", &opt)
    if err != nil {
        t.Fatal(err)
    }
    defer conn.Close()

    res, err := con.Exec("SET", "name", "your name").String()
    if err != nil {
        log.Fatal(err)
    }
    log.Println(res)

    res, err = con.Exec("GET", "name").String()
    if err != nil {
        log.Fatal(err)
    }
    log.Println(res)
Pipline
    opt := redis.Option{
        Auth: "password",
    }
    conn, err := redis.Connect("127.0.0.1", "6379", &opt)
    if err != nil {
        t.Fatal(err)
    }
    defer conn.Close()

    err = con.Pipline("SET", "name", "your name")
    if err != nil {
        log.Fatal(err)
    }

    err = con.Pipline("SET", "gender", "female")
    if err != nil {
        log.Fatal(err)
    }

    _, err := con.Commit()
    if err != nil {
        log.Fatal(err)
    }

    strs, err := con.Exec("GET", "name", "gender").Strings()
    if err != nil {
        log.Fatal(err)
    }
	log.Println(strs)

Subscribe
    opt := redis.Option{
        Auth: "password",
    }
    conn, err := redis.Connect("127.0.0.1", "6379", &opt)
    if err != nil {
        t.Fatal(err)
    }

    psc := NewPubSubConn(c, func(msg Message, err error) {

    if err != nil {
        log.Println("=====================", err)
    } else {
        log.Println("message", msg)
    }
    })
    defer psc.Close()

    psc.Subscribe("name")

Todo

  • Connection pool
  • Cluster support

License

go_redis_client code is published under MIT license

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL