package redisaccessor

import (
	"fmt"
	"os"

	"github.com/redis/go-redis/v9"
)

var redisClient *redis.Client

func Get() *redis.Client {
	return redisClient
}

func New() *redis.Client {
	var (
		username = os.Getenv("REDIS_USERNAME")
		addr     = fmt.Sprintf("%s:%s", os.Getenv("REDIS_HOST"), os.Getenv("REDIS_PORT"))
		password = os.Getenv("REDIS_PASSWORD")
		db       = 2 // TODO: change later
	)

	redisClient = redis.NewClient(&redis.Options{
		Username: username,
		Addr:     addr,
		Password: password,
		DB:       db,
	})

	return redisClient
}
