添加struct 2 hash 测试

This commit is contained in:
comin2013
2021-04-22 18:53:36 +08:00
parent 2dabef2682
commit 23e8dacdeb

View File

@@ -24,13 +24,29 @@ func Test_Example(t *testing.T) {
module.SetString(1000,2*1000)
module.SetStringExpire("key2","value2","60")
//支持直接存储struct数据
//支持直接存储struct数据(json string)
jsonData := struct{
A string
B string
}{"Aaaa","Bbbb"}
module.SetStringJSON("key3",&jsonData)
// struct 2 redis hash
a := struct{
A string `redis:"a"`
B int `redis:"b"`
}{
"ccc",
1,
}
module.HSetStruct("skey", &a)
a.A = "xx"
module.HGetStruct("skey", &a)
if a.A == "xx"{
fmt.Println("struct 2 hash failed.")
}
//支持存储map数据结构map中的key与value与redis的key,value对象
mapData := map[interface{}]interface{}{}
mapData["key4"] = "value4"