Documentation
¶
Overview ¶
Package rdx 提供 Redis 单机和 Sentinel 客户端初始化,并统一接入应用生命周期。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrAddressRequired 表示没有配置 Redis 地址。 ErrAddressRequired = errx.New("redis address must not be empty") // ErrInvalidMode 表示 Redis 连接模式不受支持。 ErrInvalidMode = errx.New("redis mode must be standalone or sentinel") // ErrStandaloneAddressCount 表示单机模式配置了不止一个地址。 ErrStandaloneAddressCount = errx.New("redis standalone mode requires exactly one address") // ErrSentinelMasterRequired 表示 Sentinel 模式没有配置主节点名称。 ErrSentinelMasterRequired = errx.New("redis sentinel master name must not be empty") // ErrInvalidDatabase 表示 Redis 数据库编号无效。 ErrInvalidDatabase = errx.New("redis database must not be negative") // ErrInvalidPoolConfig 表示 Redis 连接池参数无效。 ErrInvalidPoolConfig = errx.New("redis pool values must not be negative") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Mode Mode `json:"mode"`
Addresses []string `json:"addresses"`
MasterName string `json:"master_name"`
Username string `json:"username"`
Password string `json:"password"`
SentinelUsername string `json:"sentinel_username"`
SentinelPassword string `json:"sentinel_password"`
Database int `json:"database"`
ClientName string `json:"client_name"`
DialTimeout time.Duration `json:"dial_timeout"`
ReadTimeout time.Duration `json:"read_timeout"`
WriteTimeout time.Duration `json:"write_timeout"`
PoolTimeout time.Duration `json:"pool_timeout"`
PoolSize int `json:"pool_size"`
MinIdleConns int `json:"min_idle_conns"`
MaxIdleConns int `json:"max_idle_conns"`
MaxActiveConns int `json:"max_active_conns"`
ConnMaxIdleTime time.Duration `json:"conn_max_idle_time"`
ConnMaxLifetime time.Duration `json:"conn_max_lifetime"`
TLS TLSConfig `json:"tls"`
}
Config 定义 Redis 单机或 Sentinel 客户端参数。
Click to show internal directories.
Click to hide internal directories.