-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(redis): Implement redisNode interface for redis.Redis #5188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,8 @@ type ( | |
| StringCmd = red.StringCmd | ||
| // Script is an alias of redis.Script. | ||
| Script = red.Script | ||
| // CommandsInfoCmd is an alias of redis.CommandsInfoCmd. | ||
| CommandsInfoCmd = red.CommandsInfoCmd | ||
|
|
||
| // Hook is an alias of redis.Hook. | ||
| Hook = red.Hook | ||
|
|
@@ -243,6 +245,16 @@ func (s *Redis) BitOpXorCtx(ctx context.Context, destKey string, keys ...string) | |
| return conn.BitOpXor(ctx, destKey, keys...).Result() | ||
| } | ||
|
|
||
| // Command is the implementation of redis command command. | ||
| func (s *Redis) Command(ctx context.Context) *CommandsInfoCmd { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any scenario that we need to run
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Maybe we don't have a specific use case for this method, it was added to fully implement the required interface.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we remove this method?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
then Redis doesn't fully implement the RedisNode interface, methods like Blpop , BlpopCtx , and BlpopEx cannot accept Redis as parameters. |
||
| conn, err := getRedis(s) | ||
| if err != nil { | ||
| return nil | ||
| } | ||
|
|
||
| return conn.Command(ctx) | ||
| } | ||
|
|
||
| // BitPos is redis bitpos command implementation. | ||
| func (s *Redis) BitPos(key string, bit, start, end int64) (int64, error) { | ||
| return s.BitPosCtx(context.Background(), key, bit, start, end) | ||
|
|
@@ -1401,6 +1413,26 @@ func (s *Redis) ScriptLoadCtx(ctx context.Context, script string) (string, error | |
| return conn.ScriptLoad(ctx, script).Result() | ||
| } | ||
|
|
||
| // TxPipelined is the implementation of redis txpipelined command. | ||
kevwan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| func (s *Redis) TxPipelined(ctx context.Context, fn func(Pipeliner) error) ([]Cmder, error) { | ||
| conn, err := getRedis(s) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return conn.TxPipelined(ctx, fn) | ||
| } | ||
|
|
||
| // Pipeline is the implementation of redis pipeline command. | ||
kevwan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| func (s *Redis) Pipeline() Pipeliner { | ||
| conn, err := getRedis(s) | ||
| if err != nil { | ||
| return nil | ||
| } | ||
|
|
||
| return conn.Pipeline() | ||
| } | ||
|
|
||
| // ScriptRun is the implementation of *redis.Script run command. | ||
| func (s *Redis) ScriptRun(script *Script, keys []string, args ...any) (any, error) { | ||
| return s.ScriptRunCtx(context.Background(), script, keys, args...) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.