patch: caches torrentio movie results

This commit is contained in:
2025-05-01 21:58:02 -05:00
parent 12bf90a2b4
commit b0c10a028a

View File

@@ -20,13 +20,21 @@ final class TorrentioController extends AbstractController
) {} ) {}
#[Route('/torrentio/movies/{tmdbId}/{imdbId}', name: 'app_torrentio_movies')] #[Route('/torrentio/movies/{tmdbId}/{imdbId}', name: 'app_torrentio_movies')]
public function movieOptions(GetMovieOptionsInput $input): Response public function movieOptions(GetMovieOptionsInput $input, CacheInterface $cache): Response
{ {
$results = $this->getMovieOptionsHandler->handle($input->toCommand()); $cacheId = sprintf(
"page.torrentio.movies.%s.%s",
$input->tmdbId,
$input->imdbId
);
return $this->render('torrentio/movies.html.twig', [ return $cache->get($cacheId, function (ItemInterface $item) use ($input) {
'results' => $results, $item->expiresAt(new \DateTimeImmutable("today 11:59 pm"));
]); $results = $this->getMovieOptionsHandler->handle($input->toCommand());
return $this->render('torrentio/movies.html.twig', [
'results' => $results,
]);
});
} }
#[Route('/torrentio/tvshows/{tmdbId}/{imdbId}/{season?}/{episode?}', name: 'app_torrentio_tvshows')] #[Route('/torrentio/tvshows/{tmdbId}/{imdbId}/{season?}/{episode?}', name: 'app_torrentio_tvshows')]