mirror of https://github.com/go-redis/redis.git
Support custom command in pipeline
This commit is contained in:
parent
228e43ba24
commit
5240e1403a
|
@ -31,6 +31,12 @@ type Pipeline struct {
|
||||||
closed bool
|
closed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Pipeline) Do(args ...interface{}) *Cmd {
|
||||||
|
cmd := NewCmd(args...)
|
||||||
|
_ = c.Process(cmd)
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
// Process queues the cmd for later execution.
|
// Process queues the cmd for later execution.
|
||||||
func (c *Pipeline) Process(cmd Cmder) error {
|
func (c *Pipeline) Process(cmd Cmder) error {
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
|
|
|
@ -60,6 +60,13 @@ var _ = Describe("pipelining", func() {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(val).To(Equal("value"))
|
Expect(val).To(Equal("value"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("supports custom command", func() {
|
||||||
|
pipe.Do("ping")
|
||||||
|
cmds, err := pipe.Exec()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(cmds).To(HaveLen(1))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Describe("Pipeline", func() {
|
Describe("Pipeline", func() {
|
||||||
|
|
Loading…
Reference in New Issue