1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-18 00:20:57 +03:00

chore: remove a redundant method (#3401)

Signed-off-by: fukua95 <fukua95@gmail.com>
Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
This commit is contained in:
cxljs
2025-06-16 21:55:23 +08:00
committed by GitHub
parent e2295c7129
commit 82b00cc520
6 changed files with 18 additions and 21 deletions

View File

@ -979,13 +979,6 @@ func (c *ClusterClient) Close() error {
return c.nodes.Close() return c.nodes.Close()
} }
// Do create a Cmd from the args and processes the cmd.
func (c *ClusterClient) Do(ctx context.Context, args ...interface{}) *Cmd {
cmd := NewCmd(ctx, args...)
_ = c.Process(ctx, cmd)
return cmd
}
func (c *ClusterClient) Process(ctx context.Context, cmd Cmder) error { func (c *ClusterClient) Process(ctx context.Context, cmd Cmder) error {
err := c.processHook(ctx, cmd) err := c.processHook(ctx, cmd)
cmd.SetErr(err) cmd.SetErr(err)

View File

@ -264,6 +264,12 @@ var _ = Describe("ClusterClient", func() {
var client *redis.ClusterClient var client *redis.ClusterClient
assertClusterClient := func() { assertClusterClient := func() {
It("do", func() {
val, err := client.Do(ctx, "ping").Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
})
It("should GET/SET/DEL", func() { It("should GET/SET/DEL", func() {
err := client.Get(ctx, "A").Err() err := client.Get(ctx, "A").Err()
Expect(err).To(Equal(redis.Nil)) Expect(err).To(Equal(redis.Nil))

View File

@ -776,13 +776,6 @@ func (c *Client) Conn() *Conn {
return newConn(c.opt, pool.NewStickyConnPool(c.connPool), &c.hooksMixin) return newConn(c.opt, pool.NewStickyConnPool(c.connPool), &c.hooksMixin)
} }
// Do create a Cmd from the args and processes the cmd.
func (c *Client) Do(ctx context.Context, args ...interface{}) *Cmd {
cmd := NewCmd(ctx, args...)
_ = c.Process(ctx, cmd)
return cmd
}
func (c *Client) Process(ctx context.Context, cmd Cmder) error { func (c *Client) Process(ctx context.Context, cmd Cmder) error {
err := c.processHook(ctx, cmd) err := c.processHook(ctx, cmd)
cmd.SetErr(err) cmd.SetErr(err)

View File

@ -89,6 +89,12 @@ var _ = Describe("Client", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })
It("do", func() {
val, err := client.Do(ctx, "ping").Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
})
It("should ping", func() { It("should ping", func() {
val, err := client.Ping(ctx).Result() val, err := client.Ping(ctx).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())

View File

@ -563,13 +563,6 @@ func (c *Ring) SetAddrs(addrs map[string]string) {
c.sharding.SetAddrs(addrs) c.sharding.SetAddrs(addrs)
} }
// Do create a Cmd from the args and processes the cmd.
func (c *Ring) Do(ctx context.Context, args ...interface{}) *Cmd {
cmd := NewCmd(ctx, args...)
_ = c.Process(ctx, cmd)
return cmd
}
func (c *Ring) Process(ctx context.Context, cmd Cmder) error { func (c *Ring) Process(ctx context.Context, cmd Cmder) error {
err := c.processHook(ctx, cmd) err := c.processHook(ctx, cmd)
cmd.SetErr(err) cmd.SetErr(err)

View File

@ -74,6 +74,12 @@ var _ = Describe("Redis Ring", func() {
Expect(ring.Close()).NotTo(HaveOccurred()) Expect(ring.Close()).NotTo(HaveOccurred())
}) })
It("do", func() {
val, err := ring.Do(ctx, "ping").Result()
Expect(err).NotTo(HaveOccurred())
Expect(val).To(Equal("PONG"))
})
It("supports context", func() { It("supports context", func() {
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
cancel() cancel()