Exemple #1
0
	BeforeEach(func() {
		client = redis.NewClient(redisOptions())
		Expect(client.FlushDb().Err()).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		Expect(client.Close()).NotTo(HaveOccurred())
	})

	It("should pipeline", func() {
		set := client.Set("key2", "hello2", 0)
		Expect(set.Err()).NotTo(HaveOccurred())
		Expect(set.Val()).To(Equal("OK"))

		pipeline := client.Pipeline()
		set = pipeline.Set("key1", "hello1", 0)
		get := pipeline.Get("key2")
		incr := pipeline.Incr("key3")
		getNil := pipeline.Get("key4")

		cmds, err := pipeline.Exec()
		Expect(err).To(Equal(redis.Nil))
		Expect(cmds).To(HaveLen(4))
		Expect(pipeline.Close()).NotTo(HaveOccurred())

		Expect(set.Err()).NotTo(HaveOccurred())
		Expect(set.Val()).To(Equal("OK"))

		Expect(get.Err()).NotTo(HaveOccurred())
		Expect(get.Val()).To(Equal("hello2"))