goRedis
简介
实现redis操作
使用
go get github.com/wms3001/goRedis
实例
- 连接
goRedis := GoRedis{}
goRedis.Db = 10
goRedis.Addr = "192.168.4.81:6379"
goRedis.Password = "glredis"
goRedis.Connect()
- set
goRedis := GoRedis{}
goRedis.Db = 10
goRedis.Addr = "192.168.4.81:6379"
goRedis.Password = "glredis"
goRedis.Connect()
goRedis.Set("glkj", "6666666", 1*time.Minute)
- get
goRedis := GoRedis{}
goRedis.Db = 10
goRedis.Addr = "192.168.4.81:6379"
goRedis.Password = "glredis"
goRedis.Connect()
goRedis.Get("glkj")
- 执行命令
goRedis := GoRedis{}
goRedis.Db = 10
goRedis.Addr = "192.168.4.81:6379"
goRedis.Password = "glredis"
goRedis.Connect()
ctx := context.Background()
rel := goRedis.Client.Do(ctx, "set", "aaaa", "234234")
fmt.Println(rel)
rel1 := goRedis.Client.Do(ctx, "get", "glkj")
fmt.Println(rel1)
rel2 := goRedis.Client.Do(ctx, "setex", "glkj11", "10", "\"Hello\"")
fmt.Println(rel2)
rel3 := goRedis.Client.Do(ctx, "mset", "key1", "10", "key2", "11")
fmt.Println(rel3)