package util

import (
	"time"

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

const (
	REDIS_DBIDX_EDGE_DATA = 0
	REDIS_DBIDX_RAWDATA   = 1
)

func NewRedisClient(conf *RedisConfig, idx int) (*redis.Client, error) {
	r := redis.NewClient(&redis.Options{
		Addr:         conf.Redis_Address,
		Password:     conf.Redis_Password,
		DB:           idx,
		DialTimeout:  10 * time.Second,
		ReadTimeout:  30 * time.Second,
		WriteTimeout: 30 * time.Second,
		PoolSize:     10,
		PoolTimeout:  30 * time.Second,
	})
	return r, r.Ping().Err()
}
