安装介绍

最后更新于:2022-04-02 04:51:34

### 安装 ~~~ go get -u github.com/go-redis/redis ~~~ ### 创建客户端 ~~~ import "github.com/go-redis/redis" func RedisInit(addr string) (*redis.Client,error) { redisdb := redis.NewClient(&redis.Options{ Addr: addr, Password: "", DB: 0, PoolSize: 10, }) _,err := redisdb.Ping().Result() if err!=nil { return nil,err }else{ return redisdb,nil } } ~~~ ~~~ redisdb,err:=RedisInit("192.168.10.25:6379") ~~~ **RedisInit函数正确返回\*redis.Client(redisdb),后续所有操作都使用这个redisdb**
';