package xredis import ( "context" "fmt" "testing" "time" ) type Res struct { Name string } func TestGetData(t *testing.T) { _ = Init("localhost:6379", "", 1) res, err := GetData(context.Background(), "userId1212", func() (*Res, error) { fmt.Println("from db") in := &Res{ Name: "ttt", } return in, nil }, time.Second*50) if err != nil { t.Error(err) } fmt.Printf("%+v\n", res) }