package services

import (
	"fmt"
	"time"

	"lune/talentscale/infra/cache"
)

// RedisCacheAdapter wraps the infra/cache package to implement CacheService
type RedisCacheAdapter struct{}

// NewRedisCacheAdapter creates a new Redis cache adapter
func NewRedisCacheAdapter() CacheService {
	return &RedisCacheAdapter{}
}

func (r *RedisCacheAdapter) Get(key string) (string, error) {
	val, err := cache.Get(key)
	if err != nil {
		return "", fmt.Errorf("cache get: %w", err)
	}
	return val, nil
}

func (r *RedisCacheAdapter) Set(key string, value string, expiration time.Duration) error {
	return cache.Set(key, value, expiration)
}

func (r *RedisCacheAdapter) Del(key string) error {
	return cache.Del(key)
}

func (r *RedisCacheAdapter) DeletePattern(pattern string) error {
	return cache.DeletePattern(pattern)
}
