Template
1
0
Fork 0

Switched to REDIS_URL for ease of config

This commit is contained in:
Atridad Lahiji 2024-04-08 23:19:24 -06:00
parent cf69a91cd0
commit 3f90abe196
No known key found for this signature in database
2 changed files with 10 additions and 10 deletions

View file

@ -5,8 +5,7 @@ SMTP_PORT=""
SMTP_USERNAME=""
SMTP_PASSWORD=""
STRIPE_SECRET_KEY=""
REDIS_HOST=""
REDIS_PASSWORD=""
REDIS_URL=""
BUCKET_NAME=
AWS_REGION=
AWS_ENDPOINT_URL_S3=

View file

@ -27,15 +27,16 @@ func NewRedisClient() *redis.Client {
}
godotenv.Load(".env")
redis_host := os.Getenv("REDIS_HOST")
redis_password := os.Getenv("REDIS_PASSWORD")
redis_url := os.Getenv("REDIS_URL")
lib.LogInfo.Printf("\n[PUBSUB/REDIS]Connecting to Redis at %s\n", redis_host)
RedisClient = redis.NewClient(&redis.Options{
Addr: redis_host,
Password: redis_password,
DB: 0,
})
opts, err := redis.ParseURL(redis_url)
if err != nil {
return nil
}
lib.LogInfo.Printf("\n[PUBSUB/REDIS]Connecting to Redis at %s\n", opts.ClientName)
RedisClient = redis.NewClient(opts)
return RedisClient
}