You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
407 B
28 lines
407 B
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) |
|
}
|
|
|