Merge pull request #1991 from jiangtao244/master

feat: export cmder.SetFirstKeyPos to support build module commands
This commit is contained in:
Vladimir Mihailenco 2022-02-02 09:32:04 +02:00 committed by GitHub
commit a034b08191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View File

@ -20,7 +20,7 @@ type Cmder interface {
String() string String() string
stringArg(int) string stringArg(int) string
firstKeyPos() int8 firstKeyPos() int8
setFirstKeyPos(int8) SetFirstKeyPos(int8)
readTimeout() *time.Duration readTimeout() *time.Duration
readReply(rd *proto.Reader) error readReply(rd *proto.Reader) error
@ -159,7 +159,7 @@ func (cmd *baseCmd) firstKeyPos() int8 {
return cmd.keyPos return cmd.keyPos
} }
func (cmd *baseCmd) setFirstKeyPos(keyPos int8) { func (cmd *baseCmd) SetFirstKeyPos(keyPos int8) {
cmd.keyPos = keyPos cmd.keyPos = keyPos
} }

View File

@ -1837,7 +1837,7 @@ func (c cmdable) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd {
if a.Block >= 0 { if a.Block >= 0 {
cmd.setReadTimeout(a.Block) cmd.setReadTimeout(a.Block)
} }
cmd.setFirstKeyPos(keyPos) cmd.SetFirstKeyPos(keyPos)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -1921,7 +1921,7 @@ func (c cmdable) XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSlic
if a.Block >= 0 { if a.Block >= 0 {
cmd.setReadTimeout(a.Block) cmd.setReadTimeout(a.Block)
} }
cmd.setFirstKeyPos(keyPos) cmd.SetFirstKeyPos(keyPos)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -2397,7 +2397,7 @@ func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZSt
args = append(args, "zinterstore", destination, len(store.Keys)) args = append(args, "zinterstore", destination, len(store.Keys))
args = store.appendArgs(args) args = store.appendArgs(args)
cmd := NewIntCmd(ctx, args...) cmd := NewIntCmd(ctx, args...)
cmd.setFirstKeyPos(3) cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -2407,7 +2407,7 @@ func (c cmdable) ZInter(ctx context.Context, store *ZStore) *StringSliceCmd {
args = append(args, "zinter", len(store.Keys)) args = append(args, "zinter", len(store.Keys))
args = store.appendArgs(args) args = store.appendArgs(args)
cmd := NewStringSliceCmd(ctx, args...) cmd := NewStringSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2) cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -2418,7 +2418,7 @@ func (c cmdable) ZInterWithScores(ctx context.Context, store *ZStore) *ZSliceCmd
args = store.appendArgs(args) args = store.appendArgs(args)
args = append(args, "withscores") args = append(args, "withscores")
cmd := NewZSliceCmd(ctx, args...) cmd := NewZSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2) cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -2745,7 +2745,7 @@ func (c cmdable) ZUnion(ctx context.Context, store ZStore) *StringSliceCmd {
args = append(args, "zunion", len(store.Keys)) args = append(args, "zunion", len(store.Keys))
args = store.appendArgs(args) args = store.appendArgs(args)
cmd := NewStringSliceCmd(ctx, args...) cmd := NewStringSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2) cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -2756,7 +2756,7 @@ func (c cmdable) ZUnionWithScores(ctx context.Context, store ZStore) *ZSliceCmd
args = store.appendArgs(args) args = store.appendArgs(args)
args = append(args, "withscores") args = append(args, "withscores")
cmd := NewZSliceCmd(ctx, args...) cmd := NewZSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2) cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -2766,7 +2766,7 @@ func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *I
args = append(args, "zunionstore", dest, len(store.Keys)) args = append(args, "zunionstore", dest, len(store.Keys))
args = store.appendArgs(args) args = store.appendArgs(args)
cmd := NewIntCmd(ctx, args...) cmd := NewIntCmd(ctx, args...)
cmd.setFirstKeyPos(3) cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -2796,7 +2796,7 @@ func (c cmdable) ZDiff(ctx context.Context, keys ...string) *StringSliceCmd {
} }
cmd := NewStringSliceCmd(ctx, args...) cmd := NewStringSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2) cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -2812,7 +2812,7 @@ func (c cmdable) ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd
args[len(keys)+2] = "withscores" args[len(keys)+2] = "withscores"
cmd := NewZSliceCmd(ctx, args...) cmd := NewZSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2) cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -3088,7 +3088,7 @@ func (c cmdable) MemoryUsage(ctx context.Context, key string, samples ...int) *I
args = append(args, "SAMPLES", samples[0]) args = append(args, "SAMPLES", samples[0])
} }
cmd := NewIntCmd(ctx, args...) cmd := NewIntCmd(ctx, args...)
cmd.setFirstKeyPos(2) cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -3105,7 +3105,7 @@ func (c cmdable) Eval(ctx context.Context, script string, keys []string, args ..
} }
cmdArgs = appendArgs(cmdArgs, args) cmdArgs = appendArgs(cmdArgs, args)
cmd := NewCmd(ctx, cmdArgs...) cmd := NewCmd(ctx, cmdArgs...)
cmd.setFirstKeyPos(3) cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }
@ -3120,7 +3120,7 @@ func (c cmdable) EvalSha(ctx context.Context, sha1 string, keys []string, args .
} }
cmdArgs = appendArgs(cmdArgs, args) cmdArgs = appendArgs(cmdArgs, args)
cmd := NewCmd(ctx, cmdArgs...) cmd := NewCmd(ctx, cmdArgs...)
cmd.setFirstKeyPos(3) cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd) _ = c(ctx, cmd)
return cmd return cmd
} }