package impl

import (
	"github.com/pingcap-inc/clinic/pkg/ngm/statements/api"
	"github.com/pingcap-inc/clinic/pkg/ngm/statements/load"
	"github.com/pingcap-inc/clinic/pkg/ngm/storage"

	lru "github.com/hashicorp/golang-lru/v2"
)

const (
	CacheSize = 2000
)

type StatementImpl struct {
	env   string
	sf    storage.StorageFactory
	cache *lru.Cache[load.CacheKey, load.TimeRangeRecords]
}

var _ api.Query = (*StatementImpl)(nil)

func NewStatementImpl(env string, sf storage.StorageFactory) *StatementImpl {
	cache, _ := lru.New[load.CacheKey, load.TimeRangeRecords](CacheSize)
	return &StatementImpl{env, sf, cache}
}
