diff --git a/database/cache/new_test.go b/database/cache/new_test.go index d2ea9e8..76cea18 100644 --- a/database/cache/new_test.go +++ b/database/cache/new_test.go @@ -37,3 +37,37 @@ func TestNew(t *testing.T) { t.Fatal(err) }*/ } + +func TestNoAuth(t *testing.T) { + //if err := Init(WithRedis("10.125.1.28", 6379, "", "")); 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) + //} +} diff --git a/database/cache/option.go b/database/cache/option.go index bf8e236..bc3cf96 100644 --- a/database/cache/option.go +++ b/database/cache/option.go @@ -22,7 +22,7 @@ func WithCtx(ctx context.Context) OptionFn { func WithRedis(host string, port int, username, password string) OptionFn { return func(c *config) { - uri := fmt.Sprintf("%s:%d", host, port) + uri := fmt.Sprintf("redis://%s:%d", host, port) if username != "" || password != "" { uri = fmt.Sprintf("redis://%s:%s@%s:%d", username, password, host, port) }