File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 11* .rdb
22testdata /* /
3+ .idea /
Original file line number Diff line number Diff line change 11package redis_test
22
33import (
4+ "strconv"
5+
46 "github.com/go-redis/redis/v7"
57
68 . "github.com/onsi/ginkgo"
@@ -67,6 +69,21 @@ var _ = Describe("pipelining", func() {
6769 Expect (err ).NotTo (HaveOccurred ())
6870 Expect (cmds ).To (HaveLen (1 ))
6971 })
72+
73+ It ("handles large pipelines" , func () {
74+ for callCount := 1 ; callCount < 16 ; callCount ++ {
75+ for i := 1 ; i <= callCount ; i ++ {
76+ pipe .SetNX (strconv .Itoa (i )+ "_key" , strconv .Itoa (i )+ "_value" , 0 )
77+ }
78+
79+ cmds , err := pipe .Exec ()
80+ Expect (err ).NotTo (HaveOccurred ())
81+ Expect (cmds ).To (HaveLen (callCount ))
82+ for _ , cmd := range cmds {
83+ Expect (cmd ).To (BeAssignableToTypeOf (& redis.BoolCmd {}))
84+ }
85+ }
86+ })
7087 }
7188
7289 Describe ("Pipeline" , func () {
Original file line number Diff line number Diff line change @@ -473,11 +473,11 @@ func wrapMultiExec(cmds []Cmder) []Cmder {
473473 if len (cmds ) == 0 {
474474 panic ("not reached" )
475475 }
476- cmds = append ( cmds , make ([]Cmder , 2 ) ... )
477- copy ( cmds [ 1 :], cmds [: len ( cmds ) - 2 ] )
478- cmds [ 0 ] = NewStatusCmd ( "multi" )
479- cmds [len (cmds )- 1 ] = NewSliceCmd ("exec" )
480- return cmds
476+ cmdCopy := make ([]Cmder , len ( cmds ) + 2 )
477+ cmdCopy [ 0 ] = NewStatusCmd ( "multi" )
478+ copy ( cmdCopy [ 1 :], cmds )
479+ cmdCopy [len (cmdCopy )- 1 ] = NewSliceCmd ("exec" )
480+ return cmdCopy
481481}
482482
483483func txPipelineReadQueued (rd * proto.Reader , statusCmd * StatusCmd , cmds []Cmder ) error {
You can’t perform that action at this time.
0 commit comments