package services

import (
	"sync"

	"github.com/fiskerinc/cloud-services/pkg/cache"
	"github.com/fiskerinc/cloud-services/pkg/utils/envtool"
)

var (
	MAX_KEY_CACHE int = envtool.GetEnvInt("MAX_KEY_CACHE", 10000)
	carDtcsCache  cache.CarDTCsCacheInterface
	onceDTCCache  sync.Once
)

func GetCarDtcCache() cache.CarDTCsCacheInterface {
	onceDTCCache.Do(func() {
		if carDtcsCache == nil {
			carDtcsCache = cache.NewCarDTCsCache(MAX_KEY_CACHE)
		}
	})

	return carDtcsCache
}
