Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var HashDefaultExpire int64 = 300 // 默认过期时间300s
View Source
var RedisClientList = map[string]*redis.Client{}
a redis client list
Functions ¶
func GetRedisClient ¶
GetRedisClient get redis client from RedisClientList
Types ¶
type RedisClientConf ¶
type RedisClientConf struct { // host:port address. Address string // Optional password. Must match the password specified in the // requirepass server configuration option. Password string // Database to be selected after connecting to the server. DB int // Maximum number of retries before giving up. // Default is to not retry failed commands. MaxRetries int // Dial timeout for establishing new connections. // Default is 5 seconds. DialTimeout time.Duration // Timeout for socket reads. If reached, commands will fail // with a timeout instead of blocking. Use value -1 for no timeout and 0 for default. // Default is 3 seconds. ReadTimeout time.Duration // Timeout for socket writes. If reached, commands will fail // with a timeout instead of blocking. // Default is ReadTimeout. WriteTimeout time.Duration // Maximum number of socket connections. // Default is 10 connections per every CPU as reported by runtime.NumCPU. PoolSize int // Amount of time client waits for connection if all connections // are busy before returning an error. // Default is ReadTimeout + 1 second. PoolTimeout time.Duration // Minimum number of idle connections which is useful when establishing // new connection is slow. MinIdleConns int // Amount of time after which client closes idle connections. // Should be less than server's timeout. // Default is 5 minutes. -1 disables idle timeout check. IdleTimeout time.Duration // Connection age at which client retires (closes) the connection. // Default is to not close aged connections. MaxConnAge time.Duration }
redis client config
func (*RedisClientConf) GetClient ¶
func (conf *RedisClientConf) GetClient() *redis.Client
GetClient return redis client
func (*RedisClientConf) SetClientName ¶
func (conf *RedisClientConf) SetClientName(name string)
SetClientName set a redis client to clientList
type RedisClusterConf ¶
type RedisClusterConf struct { // A seed list of host:port addresses of cluster nodes. AddressNodes []string Password string // Maximum number of retries before giving up. // Default is to not retry failed commands. MaxRetries int DialTimeout time.Duration // Default is 5 seconds. ReadTimeout time.Duration WriteTimeout time.Duration // PoolSize applies per cluster node and not for the whole cluster. PoolSize int // Amount of time client waits for connection if all connections // are busy before returning an error. // Default is ReadTimeout + 1 second. PoolTimeout time.Duration // Minimum number of idle connections which is useful when establishing // new connection is slow. MinIdleConns int // Amount of time after which client closes idle connections. // Should be less than server's timeout. // Default is 5 minutes. -1 disables idle timeout check. IdleTimeout time.Duration // Connection age at which client retires (closes) the connection. // Default is to not close aged connections. MaxConnAge time.Duration }
redis cluster config
func (*RedisClusterConf) GetCluster ¶
func (conf *RedisClusterConf) GetCluster() *redis.ClusterClient
GetCluster return redis cluster client
Click to show internal directories.
Click to hide internal directories.