package port

import (
	"context"

	"github.com/orchard9/rdev/internal/domain"
)

// CacheProvisioner provisions isolated cache access for projects.
// Implementation uses Redis ACLs to scope each project to its own key prefix.
type CacheProvisioner interface {
	// CreateProjectCache provisions isolated cache access for a project.
	// Creates a Redis ACL user scoped to the project's key prefix.
	// Returns credentials that should be injected into the project's environment.
	CreateProjectCache(ctx context.Context, projectID string) (*domain.CacheCredentials, error)

	// DeleteProjectCache removes cache access for a project.
	// Deletes the Redis ACL user and optionally purges all project keys.
	DeleteProjectCache(ctx context.Context, projectID string, purgeKeys bool) error

	// GetProjectCache retrieves cache credentials for a project.
	// Returns nil if the project has no cache provisioned.
	GetProjectCache(ctx context.Context, projectID string) (*domain.CacheCredentials, error)

	// TestConnection verifies the cache provisioner can connect to Redis.
	TestConnection(ctx context.Context) error
}
