140 lines
2.9 KiB
Go
140 lines
2.9 KiB
Go
package config
|
|
|
|
type redisConfig struct {
|
|
Addr string `json:"addr" yaml:"addr"`
|
|
Username string `json:"username" yaml:"username"`
|
|
Password string `json:"password" yaml:"password"`
|
|
DB int `json:"db" yaml:"db"`
|
|
RESP int `json:"resp" yaml:"resp"`
|
|
DialTimeout int `json:"dialtimeout" yaml:"dialtimeout"`
|
|
ReadTimeout int `json:"readtimeout" yaml:"readtimeout"`
|
|
WriteTimeout int `json:"writetimeout" yaml:"writetimeout"`
|
|
PoolSize int `json:"poolsize" yaml:"poolsize"`
|
|
}
|
|
|
|
func (config *redisConfig) GetAddr() string {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.Addr
|
|
}
|
|
|
|
func (config *redisConfig) SetAddr(addr string) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.Addr = addr
|
|
}
|
|
|
|
func (config *redisConfig) GetUsername() string {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.Username
|
|
}
|
|
|
|
func (config *redisConfig) SetUsername(username string) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.Username = username
|
|
}
|
|
|
|
func (config *redisConfig) GetPassword() string {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.Password
|
|
}
|
|
|
|
func (config *redisConfig) SetPassword(password string) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.Password = password
|
|
}
|
|
|
|
func (config *redisConfig) GetDB() int {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.DB
|
|
}
|
|
|
|
func (config *redisConfig) SetDB(db int) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.DB = db
|
|
}
|
|
|
|
func (config *redisConfig) GetRESP() int {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.RESP
|
|
}
|
|
|
|
func (config *redisConfig) SetRESP(resp int) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.RESP = resp
|
|
}
|
|
|
|
func (config *redisConfig) GetDialTimeout() int {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.DialTimeout
|
|
}
|
|
|
|
func (config *redisConfig) SetDialTimeout(dialTimeout int) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.DialTimeout = dialTimeout
|
|
}
|
|
|
|
func (config *redisConfig) GetReadTimeout() int {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.ReadTimeout
|
|
}
|
|
|
|
func (config *redisConfig) SetReadTimeout(readTimeout int) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.ReadTimeout = readTimeout
|
|
}
|
|
|
|
func (config *redisConfig) GetWriteTimeout() int {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.WriteTimeout
|
|
}
|
|
|
|
func (config *redisConfig) SetWriteTimeout(writeTimeout int) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.WriteTimeout = writeTimeout
|
|
}
|
|
|
|
func (config *redisConfig) GetPoolSize() int {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
return config.PoolSize
|
|
}
|
|
|
|
func (config *redisConfig) SetPoolSIze(poolSize int) {
|
|
if config == nil {
|
|
panic("redis config is nil")
|
|
}
|
|
config.PoolSize = poolSize
|
|
}
|