feat(*.php): refactor, clean up and abstract dynamic page code
This commit is contained in:
parent
2f9038dccb
commit
60be0ed01d
30 changed files with 318 additions and 401 deletions
19
api/Classes/MovieFetcher.php
Normal file
19
api/Classes/MovieFetcher.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classes;
|
||||
|
||||
class MovieFetcher extends PageFetcher
|
||||
{
|
||||
public function fetch(string $url): ?array
|
||||
{
|
||||
$cacheKey = "movie_" . md5($url);
|
||||
$cached = $this->cacheGet($cacheKey);
|
||||
if ($cached) return $cached;
|
||||
|
||||
$movie = $this->fetchSingleFromApi("optimized_movies", $url);
|
||||
if (!$movie) return null;
|
||||
|
||||
$this->cacheSet($cacheKey, $movie);
|
||||
return $movie;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue