Compare commits
No commits in common. "master" and "v0.0.3" have entirely different histories.
3
database/cache/cache.go
vendored
3
database/cache/cache.go
vendored
@ -52,9 +52,6 @@ type Cache interface {
|
|||||||
GetDel(ctx context.Context, key string) ([]byte, error)
|
GetDel(ctx context.Context, key string) ([]byte, error)
|
||||||
GetDelScan(ctx context.Context, key string) Scanner
|
GetDelScan(ctx context.Context, key string) Scanner
|
||||||
Close()
|
Close()
|
||||||
// Client return raw client
|
|
||||||
// !!! dangerous api
|
|
||||||
Client() any
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
34
database/cache/new_test.go
vendored
34
database/cache/new_test.go
vendored
@ -37,37 +37,3 @@ func TestNew(t *testing.T) {
|
|||||||
t.Fatal(err)
|
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)
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
2
database/cache/option.go
vendored
2
database/cache/option.go
vendored
@ -22,7 +22,7 @@ func WithCtx(ctx context.Context) OptionFn {
|
|||||||
|
|
||||||
func WithRedis(host string, port int, username, password string) OptionFn {
|
func WithRedis(host string, port int, username, password string) OptionFn {
|
||||||
return func(c *config) {
|
return func(c *config) {
|
||||||
uri := fmt.Sprintf("redis://%s:%d", host, port)
|
uri := fmt.Sprintf("%s:%d", host, port)
|
||||||
if username != "" || password != "" {
|
if username != "" || password != "" {
|
||||||
uri = fmt.Sprintf("redis://%s:%s@%s:%d", username, password, host, port)
|
uri = fmt.Sprintf("redis://%s:%s@%s:%d", username, password, host, port)
|
||||||
}
|
}
|
||||||
|
4
database/cache/redis.go
vendored
4
database/cache/redis.go
vendored
@ -18,10 +18,6 @@ type _redis struct {
|
|||||||
client *redis.Client
|
client *redis.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *_redis) Client() any {
|
|
||||||
return r.client
|
|
||||||
}
|
|
||||||
|
|
||||||
func newRedis(ctx context.Context, client *redis.Client) *_redis {
|
func newRedis(ctx context.Context, client *redis.Client) *_redis {
|
||||||
r := &_redis{ctx: ctx, client: client}
|
r := &_redis{ctx: ctx, client: client}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user