1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Make Pipeline thread-safe. Fixes #166.

This commit is contained in:
Vladimir Mihailenco
2015-11-04 14:25:48 +02:00
parent a2dba7df0c
commit d0d3920e69
3 changed files with 74 additions and 10 deletions

View File

@ -150,4 +150,25 @@ var _ = Describe("Pipelining", func() {
wg.Wait()
})
It("should be thread-safe", func() {
const N = 1000
pipeline := client.Pipeline()
wg := &sync.WaitGroup{}
wg.Add(N)
for i := 0; i < N; i++ {
go func() {
pipeline.Ping()
wg.Done()
}()
}
wg.Wait()
cmds, err := pipeline.Exec()
Expect(err).NotTo(HaveOccurred())
Expect(cmds).To(HaveLen(N))
Expect(pipeline.Close()).NotTo(HaveOccurred())
})
})