mirror of https://github.com/go-redis/redis.git
only set opt.IdleTimeout in It("reuses connections")
Signed-off-by: monkey <golang@88.com>
This commit is contained in:
parent
42b2a72e66
commit
7d2e85eff6
11
pool_test.go
11
pool_test.go
|
@ -17,7 +17,7 @@ var _ = Describe("pool", func() {
|
||||||
opt := redisOptions()
|
opt := redisOptions()
|
||||||
opt.MinIdleConns = 0
|
opt.MinIdleConns = 0
|
||||||
opt.MaxConnAge = 0
|
opt.MaxConnAge = 0
|
||||||
opt.IdleTimeout = 2 * time.Second
|
opt.IdleTimeout = time.Second
|
||||||
client = redis.NewClient(opt)
|
client = redis.NewClient(opt)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -105,6 +105,13 @@ var _ = Describe("pool", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("reuses connections", func() {
|
It("reuses connections", func() {
|
||||||
|
// explain: https://github.com/go-redis/redis/pull/1675
|
||||||
|
opt := redisOptions()
|
||||||
|
opt.MinIdleConns = 0
|
||||||
|
opt.MaxConnAge = 0
|
||||||
|
opt.IdleTimeout = 2 * time.Second
|
||||||
|
client = redis.NewClient(opt)
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
val, err := client.Ping(ctx).Result()
|
val, err := client.Ping(ctx).Result()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
@ -135,7 +142,7 @@ var _ = Describe("pool", func() {
|
||||||
StaleConns: 0,
|
StaleConns: 0,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
time.Sleep(3 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
|
|
||||||
stats = client.PoolStats()
|
stats = client.PoolStats()
|
||||||
Expect(stats).To(Equal(&redis.PoolStats{
|
Expect(stats).To(Equal(&redis.PoolStats{
|
||||||
|
|
Loading…
Reference in New Issue