2023-04-24 20:52:12 +02:00
|
|
|
package config
|
|
|
|
|
2024-02-15 15:17:57 +01:00
|
|
|
import "time"
|
|
|
|
|
2023-04-24 20:52:12 +02:00
|
|
|
const (
|
|
|
|
RedisModeSimple = "simple"
|
|
|
|
RedisModeSentinel = "sentinel"
|
|
|
|
RedisModeCluster = "cluster"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RedisConfig struct {
|
2024-04-05 10:30:34 +02:00
|
|
|
Adresses InterpolatedStringSlice `yaml:"addresses"`
|
|
|
|
Master InterpolatedString `yaml:"master"`
|
|
|
|
ReadTimeout InterpolatedDuration `yaml:"readTimeout"`
|
|
|
|
WriteTimeout InterpolatedDuration `yaml:"writeTimeout"`
|
|
|
|
DialTimeout InterpolatedDuration `yaml:"dialTimeout"`
|
|
|
|
LockMaxRetries InterpolatedInt `yaml:"lockMaxRetries"`
|
2024-09-23 15:16:30 +02:00
|
|
|
MaxRetries InterpolatedInt `yaml:"maxRetries"`
|
|
|
|
PingInterval InterpolatedDuration `yaml:"pingInterval"`
|
2023-04-24 20:52:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewDefaultRedisConfig() RedisConfig {
|
|
|
|
return RedisConfig{
|
2024-04-05 10:30:34 +02:00
|
|
|
Adresses: InterpolatedStringSlice{"localhost:6379"},
|
|
|
|
Master: "",
|
|
|
|
ReadTimeout: InterpolatedDuration(30 * time.Second),
|
|
|
|
WriteTimeout: InterpolatedDuration(30 * time.Second),
|
|
|
|
DialTimeout: InterpolatedDuration(30 * time.Second),
|
|
|
|
LockMaxRetries: 10,
|
2024-09-23 15:16:30 +02:00
|
|
|
MaxRetries: 3,
|
|
|
|
PingInterval: InterpolatedDuration(30 * time.Second),
|
2023-04-24 20:52:12 +02:00
|
|
|
}
|
|
|
|
}
|