All Projects → philchia → Go_redis_client

philchia / Go_redis_client

Licence: mit
go_redis_client is a redis client for golang

Programming Languages

go
31211 projects - #10 most used programming language

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].