34 lines
581 B
Go
34 lines
581 B
Go
|
|
package diagram
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"fmt"
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/redis/go-redis/v9"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestHMSet(t *testing.T) {
|
||
|
|
rdb := redis.NewClient(&redis.Options{
|
||
|
|
Network: "tcp",
|
||
|
|
Addr: "192.168.2.104:6379",
|
||
|
|
Password: "cnstar",
|
||
|
|
PoolSize: 50,
|
||
|
|
DialTimeout: 10 * time.Second,
|
||
|
|
})
|
||
|
|
params := map[string]interface{}{
|
||
|
|
"field1": "Hello1",
|
||
|
|
"field2": "World1",
|
||
|
|
"field3": 11,
|
||
|
|
}
|
||
|
|
|
||
|
|
ctx := context.Background()
|
||
|
|
res, err := rdb.HSet(ctx, "myhash", params).Result()
|
||
|
|
if err != nil {
|
||
|
|
fmt.Printf("err:%v\n", err)
|
||
|
|
}
|
||
|
|
fmt.Printf("res:%v\n", res)
|
||
|
|
return
|
||
|
|
}
|