1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Add support for connection initialisation.

This commit is contained in:
Vladimir Mihailenco
2012-08-06 11:33:49 +03:00
parent 4e6fa48b48
commit c5c8ec6b0c
4 changed files with 116 additions and 20 deletions

View File

@ -11,7 +11,10 @@ Example 1:
import "github.com/vmihailenco/redis"
redisClient := redis.NewTCPClient(":6379", "", 0)
address := ":6379"
password := "secret"
db := 0
redisClient := redis.NewTCPClient(address, password, db)
Example 2:
@ -29,7 +32,7 @@ Example 2:
return nil
}
initConn := func(client *Client) error {
initConn := func(client *redis.Client) error {
_, err := client.Auth("foo").Reply()
if err != nil {
return err
@ -45,7 +48,7 @@ Example 2:
redisClient := redis.NewClient(openConn, closeConn, initConn)
`closeConn` and `initConn` functions can be `nil`.
Both `closeConn` and `initConn` functions can be `nil`.
Running commands
----------------
@ -199,4 +202,4 @@ Connection pool
Client uses connection pool with default capacity of 10 connections. To change pool capacity:
redisClient.ConnPool.MaxCap = 1
redisClient.ConnPool.(*redis.MultiConnPool).MaxCap = 1