<?php
declare(strict_types=1);
namespace App\Domains\Word\Domain\Service;
use App\Domains\Word\Infrastructure\Repository\WordCacheRepository;
class WordCacheService
{
public function __construct(
private readonly WordCacheRepository $wordCacheRepository,
) {
}
public function cacheWord(
array $wordArray,
int $userId,
int $ttl = 3600,
): void {
$this->wordCacheRepository->cacheWord($wordArray, $userId, $ttl);
}
public function getWord(
string $wordText,
string $fromLang,
string $toLang,
int $userId,
): array|null {
return $this->wordCacheRepository->getWord($wordText, $fromLang, $toLang, $userId);
}
}