func ExampleNewRing() { client := redis.NewRing(&redis.RingOptions{ Addrs: map[string]string{ "shard1": ":7000", "shard2": ":7001", "shard3": ":7002", }, }) client.Ping() }
) var _ = Describe("Redis ring", func() { var ring *redis.Ring setRingKeys := func() { for i := 0; i < 100; i++ { err := ring.Set(fmt.Sprintf("key%d", i), "value", 0).Err() Expect(err).NotTo(HaveOccurred()) } } BeforeEach(func() { ring = redis.NewRing(&redis.RingOptions{ Addrs: map[string]string{ "ringShardOne": ":" + ringShard1Port, "ringShardTwo": ":" + ringShard2Port, }, }) // Shards should not have any keys. Expect(ringShard1.FlushDb().Err()).NotTo(HaveOccurred()) Expect(ringShard1.Info().Val()).NotTo(ContainSubstring("keys=")) Expect(ringShard2.FlushDb().Err()).NotTo(HaveOccurred()) Expect(ringShard2.Info().Val()).NotTo(ContainSubstring("keys=")) }) AfterEach(func() { Expect(ring.Close()).NotTo(HaveOccurred()) })