1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00
This commit is contained in:
Vladimir Mihailenco
2020-09-23 10:29:13 +03:00
parent c89b69131d
commit a32502b1d9
2 changed files with 30 additions and 28 deletions

View File

@ -1505,19 +1505,19 @@ func (c cmdable) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd {
args := make([]interface{}, 0, 5+len(a.Streams))
args = append(args, "xread")
offset := 1
keyPos := int8(1)
if a.Count > 0 {
args = append(args, "count")
args = append(args, a.Count)
offset += 2
keyPos += 2
}
if a.Block >= 0 {
args = append(args, "block")
args = append(args, int64(a.Block/time.Millisecond))
offset += 2
keyPos += 2
}
args = append(args, "streams")
offset += 1
keyPos += 1
for _, s := range a.Streams {
args = append(args, s)
}
@ -1526,7 +1526,7 @@ func (c cmdable) XRead(ctx context.Context, a *XReadArgs) *XStreamSliceCmd {
if a.Block >= 0 {
cmd.setReadTimeout(a.Block)
}
cmd.addKeyPos(offset)
cmd.setFirstKeyPos(keyPos)
_ = c(ctx, cmd)
return cmd
}
@ -1581,21 +1581,21 @@ func (c cmdable) XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSlic
args := make([]interface{}, 0, 8+len(a.Streams))
args = append(args, "xreadgroup", "group", a.Group, a.Consumer)
offset := 1
keyPos := int8(1)
if a.Count > 0 {
args = append(args, "count", a.Count)
offset += 2
keyPos += 2
}
if a.Block >= 0 {
args = append(args, "block", int64(a.Block/time.Millisecond))
offset += 2
keyPos += 2
}
if a.NoAck {
args = append(args, "noack")
offset += 1
keyPos += 1
}
args = append(args, "streams")
offset += 1
keyPos += 1
for _, s := range a.Streams {
args = append(args, s)
}
@ -1604,7 +1604,7 @@ func (c cmdable) XReadGroup(ctx context.Context, a *XReadGroupArgs) *XStreamSlic
if a.Block >= 0 {
cmd.setReadTimeout(a.Block)
}
cmd.addKeyPos(offset)
cmd.setFirstKeyPos(keyPos)
_ = c(ctx, cmd)
return cmd
}
@ -1883,7 +1883,7 @@ func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZSt
args = append(args, "aggregate", store.Aggregate)
}
cmd := NewIntCmd(ctx, args...)
cmd.addKeyPos(3)
cmd.setFirstKeyPos(3)
_ = c(ctx, cmd)
return cmd
}
@ -2118,8 +2118,9 @@ func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *I
if store.Aggregate != "" {
args = append(args, "aggregate", store.Aggregate)
}
cmd := NewIntCmd(ctx, args...)
cmd.addKeyPos(3)
cmd.setFirstKeyPos(3)
_ = c(ctx, cmd)
return cmd
}