goRedis

时间:2022-10-17 21:57:21

goRedis

简介

实现redis操作

使用

go get github.com/wms3001/goRedis

实例

  1. 连接
goRedis := GoRedis{}
goRedis.Db = 10
goRedis.Addr = "192.168.4.81:6379"
goRedis.Password = "glredis"
goRedis.Connect()
  1. 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)
  1. get
goRedis := GoRedis{}
goRedis.Db = 10
goRedis.Addr = "192.168.4.81:6379"
goRedis.Password = "glredis"
goRedis.Connect()
goRedis.Get("glkj")
  1. 执行命令
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)

相关文章