浏览代码

Improve pool documentation

- Show how to use time in TestOnBorrow.
- Note that the example is an example, not a recommendation.
Gary Burd 9 年之前
父节点
当前提交
a6abb2845e
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      redis/pool.go

+ 5 - 1
redis/pool.go

@@ -46,7 +46,8 @@ var (
 //
 // The following example shows how to use a pool in a web application. The
 // application creates a pool at application startup and makes it available to
-// request handlers using a global variable.
+// request handlers using a global variable. The pool configuration used here
+// is an example, not a recommendation. 
 //
 //  func newPool(server, password string) *redis.Pool {
 //      return &redis.Pool{
@@ -64,6 +65,9 @@ var (
 //              return c, err
 //          },
 //          TestOnBorrow: func(c redis.Conn, t time.Time) error {
+//              if time.Since(t) < time.Minute {
+//                  return nil
+//              }
 //              _, err := c.Do("PING")
 //              return err
 //          },