Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RedisPoolList = map[string]*redis.Pool{} // 存放连接池信息
Functions ¶
func GetRedisClient ¶
GetRedisClient 通过指定name获取池子中的redis连接句柄
func NewRedisPool ¶
NewRedisPool 创建redis pool连接池 If Wait is true and the pool is at the MaxActive limit, then Get() waits for a connection to be returned to the pool before returning.
TestOnBorrow is an optional application supplied function for checking the health of an idle connection before the connection is used again by the application. Argument t is the time that the connection was returned to the pool. If the function returns an error, then the connection is closed.
Types ¶
type RedisConf ¶
type RedisConf struct { Host string Port int Password string Database int MaxIdle int // 空闲pool个数 MaxActive int // 最大激活数量 ConnectTimeout int // 连接超时,单位s ReadTimeout int // 读取超时 WriteTimeout int // 写入超时 // Close connections after remaining idle for this duration. If the value // is zero, then idle connections are not closed. Applications should set // the timeout to a value less than the server's timeout. IdleTimeout int // 空闲连接超时,单位s // Close connections older than this duration. If the value is zero, then // the pool does not close connections based on age. MaxConnLifetime int // 连接最大生命周期,单位s,默认1800s }
RedisConf redis连接信息 redigo实现集群参考: go get github.com/chasex/redis-go-cluster
func (*RedisConf) SetRedisPool ¶
SetRedisPool 设置redis连接池
Click to show internal directories.
Click to hide internal directories.