Skip to content

Commit

Permalink
*redis.Client->redis.Cmdable
Browse files Browse the repository at this point in the history
  • Loading branch information
mingye.fan authored and mingye.fan committed Nov 16, 2021
1 parent 9e0fbef commit 2833592
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion xredis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/go-redis/redis/v8"
)

// NewClient returns a client to the Redis Server specified by Options.
// Deprecated: Use NewRedisClient instead.
func NewClient(opt *Options) *Client {
if opt.Tag == "" {
opt.Tag = "json"
Expand All @@ -18,6 +18,20 @@ func NewClient(opt *Options) *Client {
return &Client{Cmdable: client, options: *opt}
}

func NewRedisClient(client redis.Cmdable, opts ...Option) *Client {
opt := &Options{}
for _, option := range opts {
option(opt)
}
if opt.Tag == "" {
opt.Tag = "json"
}
if opt.Expiration == 0 {
opt.Expiration = -1
}
return &Client{Cmdable: client, options: *opt}
}

type Client struct {
redis.Cmdable
options Options
Expand Down

0 comments on commit 2833592

Please sign in to comment.