Skip to content

Commit

Permalink
Merge pull request #1991 from jiangtao244/master
Browse files Browse the repository at this point in the history
feat: export cmder.SetFirstKeyPos to support build module commands
  • Loading branch information
vmihailenco committed Feb 2, 2022
2 parents 8ed766b + f4bf09c commit a034b08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions command.go
Expand Up @@ -20,7 +20,7 @@ type Cmder interface {
String() string
stringArg(int) string
firstKeyPos() int8
setFirstKeyPos(int8)
SetFirstKeyPos(int8)

readTimeout() *time.Duration
readReply(rd *proto.Reader) error
Expand Down Expand Up @@ -159,7 +159,7 @@ func (cmd *baseCmd) firstKeyPos() int8 {
return cmd.keyPos
}

func (cmd *baseCmd) setFirstKeyPos(keyPos int8) {
func (cmd *baseCmd) SetFirstKeyPos(keyPos int8) {
cmd.keyPos = keyPos
}

Expand Down
26 changes: 13 additions & 13 deletions commands.go
Expand Up @@ -1837,7 +1837,7 @@ func (c cmdable) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd {
if a.Block >= 0 {
cmd.setReadTimeout(a.Block)
}
cmd.setFirstKeyPos(keyPos)
cmd.SetFirstKeyPos(keyPos)
_ = c(ctx, cmd)
return cmd
}
Expand Down Expand Up @@ -1921,7 +1921,7 @@ func (c cmdable) XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSlic
if a.Block >= 0 {
cmd.setReadTimeout(a.Block)
}
cmd.setFirstKeyPos(keyPos)
cmd.SetFirstKeyPos(keyPos)
_ = c(ctx, cmd)
return cmd
}
Expand Down Expand Up @@ -2397,7 +2397,7 @@ func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZSt
args = append(args, "zinterstore", destination, len(store.Keys))
args = store.appendArgs(args)
cmd := NewIntCmd(ctx, args...)
cmd.setFirstKeyPos(3)
cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd)
return cmd
}
Expand All @@ -2407,7 +2407,7 @@ func (c cmdable) ZInter(ctx context.Context, store *ZStore) *StringSliceCmd {
args = append(args, "zinter", len(store.Keys))
args = store.appendArgs(args)
cmd := NewStringSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Expand All @@ -2418,7 +2418,7 @@ func (c cmdable) ZInterWithScores(ctx context.Context, store *ZStore) *ZSliceCmd
args = store.appendArgs(args)
args = append(args, "withscores")
cmd := NewZSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Expand Down Expand Up @@ -2745,7 +2745,7 @@ func (c cmdable) ZUnion(ctx context.Context, store ZStore) *StringSliceCmd {
args = append(args, "zunion", len(store.Keys))
args = store.appendArgs(args)
cmd := NewStringSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Expand All @@ -2756,7 +2756,7 @@ func (c cmdable) ZUnionWithScores(ctx context.Context, store ZStore) *ZSliceCmd
args = store.appendArgs(args)
args = append(args, "withscores")
cmd := NewZSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Expand All @@ -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 = store.appendArgs(args)
cmd := NewIntCmd(ctx, args...)
cmd.setFirstKeyPos(3)
cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd)
return cmd
}
Expand Down Expand Up @@ -2796,7 +2796,7 @@ func (c cmdable) ZDiff(ctx context.Context, keys ...string) *StringSliceCmd {
}

cmd := NewStringSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Expand All @@ -2812,7 +2812,7 @@ func (c cmdable) ZDiffWithScores(ctx context.Context, keys ...string) *ZSliceCmd
args[len(keys)+2] = "withscores"

cmd := NewZSliceCmd(ctx, args...)
cmd.setFirstKeyPos(2)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Expand Down Expand Up @@ -3088,7 +3088,7 @@ func (c cmdable) MemoryUsage(ctx context.Context, key string, samples ...int) *I
args = append(args, "SAMPLES", samples[0])
}
cmd := NewIntCmd(ctx, args...)
cmd.setFirstKeyPos(2)
cmd.SetFirstKeyPos(2)
_ = c(ctx, cmd)
return cmd
}
Expand All @@ -3105,7 +3105,7 @@ func (c cmdable) Eval(ctx context.Context, script string, keys []string, args ..
}
cmdArgs = appendArgs(cmdArgs, args)
cmd := NewCmd(ctx, cmdArgs...)
cmd.setFirstKeyPos(3)
cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd)
return cmd
}
Expand All @@ -3120,7 +3120,7 @@ func (c cmdable) EvalSha(ctx context.Context, sha1 string, keys []string, args .
}
cmdArgs = appendArgs(cmdArgs, args)
cmd := NewCmd(ctx, cmdArgs...)
cmd.setFirstKeyPos(3)
cmd.SetFirstKeyPos(3)
_ = c(ctx, cmd)
return cmd
}
Expand Down

0 comments on commit a034b08

Please sign in to comment.