package services

import (
	"sync"

	"github.com/fiskerinc/cloud-services/pkg/redis"
)

var (
	clientPoolOnce sync.Once
	clientPool     redis.ClientPoolInterface
)

func RedisClientPool() redis.ClientPoolInterface {
	clientPoolOnce.Do(func() {
		if clientPool != nil {
			return
		}

		clientPool = redis.NewClientPool()
	})

	return clientPool
}

func SetRedisClientPool(cp redis.ClientPoolInterface) {
	clientPool = cp
}
