func main() { //设置redis服务器地址 spac := redis.DefaultSpec().Host("202.108.33.173") log.Print("spac:", spac) //创建一个异步的client Client, err := redis.NewAsynchClientWithSpec(spac) if err != nil { log.Fatal(err) } log.Println("Redis: ", Client) //get x k := "x" futureBytes, err := Client.Get(k) if err != nil { log.Panicln(err) } v, _ := futureBytes.Get(); log.Println(k, "=", string(v)) //set x v1 := "你好" futureBool, e := Client.Set(k, []byte(v1)) if e != nil { log.Print(e); } //get return value boolx , _ := futureBool.Get(); log.Printf("set %s=>%B", k, boolx); }
有疑问加站长微信联系(非本文作者)