1
0
mirror of https://github.com/redis/go-redis.git synced 2025-04-16 09:23:06 +03:00

added Do method for raw query by single conn from pool.Conn() (#3182)

* added `Do` method for raw query by single conn from `pool.Conn()`

* added test to cmdble Do method

* fixed test

* moved Do cmd to commands.go

---------

Co-authored-by: Oleg Laktyushkin <oglaktyushkin@avito.ru>
Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
This commit is contained in:
Oleglacto 2025-03-24 19:36:21 +03:00 committed by GitHub
parent 97f7530415
commit 132818033b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -422,6 +422,12 @@ func (c cmdable) Ping(ctx context.Context) *StatusCmd {
return cmd
}
func (c cmdable) Do(ctx context.Context, args ...interface{}) *Cmd {
cmd := NewCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
func (c cmdable) Quit(_ context.Context) *StatusCmd {
panic("not implemented")
}

View File

@ -84,6 +84,12 @@ var _ = Describe("Commands", func() {
Expect(ping.Val()).To(Equal("PONG"))
})
It("should Ping with Do method", func() {
result := client.Conn().Do(ctx, "PING")
Expect(result.Err()).NotTo(HaveOccurred())
Expect(result.Val()).To(Equal("PONG"))
})
It("should Wait", func() {
const wait = 3 * time.Second