40 lines
668 B
Go
40 lines
668 B
Go
package cache
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestNew(t *testing.T) {
|
|
/* if err := Init(WithRedis("127.0.0.1", 6379, "", "MyPassw0rd")); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
type User struct {
|
|
Name string `json:"name"`
|
|
Age int `json:"age"`
|
|
}
|
|
|
|
if err := Default.Set(t.Context(), "zyp:haha", &User{
|
|
Name: "cache",
|
|
Age: 18,
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
s := Default.GetDelScan(t.Context(), "zyp:haha")
|
|
u := new(User)
|
|
|
|
if err := s.Scan(u); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
t.Logf("%#v", *u)
|
|
|
|
if err := Default.SetEx(t.Context(), "zyp:haha", &User{
|
|
Name: "redis",
|
|
Age: 2,
|
|
}, time.Hour); err != nil {
|
|
t.Fatal(err)
|
|
}*/
|
|
}
|