From 3e613eebaf9f5de021ef017c22f7349bac6b3e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=87=91=E5=AF=8C?= Date: Tue, 21 Aug 2018 10:34:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20gredis.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/database/gredis/gredis.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/g/database/gredis/gredis.go b/g/database/gredis/gredis.go index ac7366645..8637f9804 100644 --- a/g/database/gredis/gredis.go +++ b/g/database/gredis/gredis.go @@ -69,6 +69,11 @@ func New(config Config) *Redis { } return c, nil }, + // 用来测试连接是否可用 + TestOnBorrow: func(c redis.Conn, t time.Time) error { + _, err := c.Do("PING") + return err + }, } pools.Set(poolKey, pool) r.pool = pool