package config var ( _redisConfig *RedisConfig ) type RedisConfig struct { Cluster bool `yaml:"cluster,omitempty"` Password string `yaml:"pwd,omitempty"` // 集群模式不生效 Host string `yaml:"host,omitempty"` // 集群模式不生效 DatabaseIndex int `yaml:"db,omitempty"` // 集群模式不生效 Port int `yaml:"port,omitempty"` // 集群模式不生效 PoolSize int `yaml:"pool-size,omitempty"` ClusterAddr *[]RedisClusterConfig `yaml:"cluster-addr,omitempty"` } type RedisClusterConfig struct { Host string `yaml:"host,omitempty"` Port int `yaml:"port,omitempty"` } func InitRedis(path string) { var config RedisConfig readConfig(path, &config) _redisConfig = &config } func GetRedisConfig() RedisConfig { return *_redisConfig }