feat(redis): add REDIS_USERNAME support for Redis ACL
This commit is contained in:
@@ -149,6 +149,7 @@ type StreamManagerConfig struct {
|
||||
// RedisConfig Redis配置
|
||||
type RedisConfig struct {
|
||||
Address string `yaml:"address" json:"address"` // Redis地址
|
||||
Username string `yaml:"username" json:"username"` // Redis用户名
|
||||
Password string `yaml:"password" json:"password"` // Redis密码
|
||||
DB int `yaml:"db" json:"db"` // Redis数据库
|
||||
Prefix string `yaml:"prefix" json:"prefix"` // 键前缀
|
||||
|
||||
@@ -238,6 +238,7 @@ func initRedisClient() (*redis.Client, error) {
|
||||
|
||||
client := redis.NewClient(&redis.Options{
|
||||
Addr: os.Getenv("REDIS_ADDR"),
|
||||
Username: os.Getenv("REDIS_USERNAME"),
|
||||
Password: os.Getenv("REDIS_PASSWORD"),
|
||||
DB: db,
|
||||
})
|
||||
|
||||
@@ -25,6 +25,7 @@ func NewStreamManager() (interfaces.StreamManager, error) {
|
||||
ttl := time.Hour // 默认1小时
|
||||
return NewRedisStreamManager(
|
||||
os.Getenv("REDIS_ADDR"),
|
||||
os.Getenv("REDIS_USERNAME"),
|
||||
os.Getenv("REDIS_PASSWORD"),
|
||||
db,
|
||||
os.Getenv("REDIS_PREFIX"),
|
||||
|
||||
@@ -18,11 +18,12 @@ type RedisStreamManager struct {
|
||||
}
|
||||
|
||||
// NewRedisStreamManager creates a new Redis-based stream manager
|
||||
func NewRedisStreamManager(redisAddr, redisPassword string,
|
||||
func NewRedisStreamManager(redisAddr, redisUsername, redisPassword string,
|
||||
redisDB int, prefix string, ttl time.Duration,
|
||||
) (*RedisStreamManager, error) {
|
||||
client := redis.NewClient(&redis.Options{
|
||||
Addr: redisAddr,
|
||||
Username: redisUsername,
|
||||
Password: redisPassword,
|
||||
DB: redisDB,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user