ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
> ### 第十例 Redis集群连接 ~~~ package main import ( "github.com/go-redis/redis" "fmt" ) func main() { redisDb := redis.NewClusterClient(&redis.ClusterOptions{ Addrs: []string{"192.168.1.170:8001", "192.168.1.171:8003", "192.168.1.172:8005"}, }) if err := redisDb.Set("name1", "winnie", 0).Err(); err != nil { fmt.Println(err) } val, err := redisDb.Get("name1").Result() if err != nil { fmt.Println(err) } fmt.Println("name1:", val) } ~~~