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/ArtistFetcher.php
Normal file
19
api/Classes/ArtistFetcher.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classes;
|
||||
|
||||
class ArtistFetcher extends PageFetcher
|
||||
{
|
||||
public function fetch(string $url): ?array
|
||||
{
|
||||
$cacheKey = "artist_" . md5($url);
|
||||
$cached = $this->cacheGet($cacheKey);
|
||||
if ($cached) return $cached;
|
||||
|
||||
$artist = $this->fetchSingleFromApi("optimized_artists", $url);
|
||||
if (!$artist) return null;
|
||||
|
||||
$this->cacheSet($cacheKey, $artist);
|
||||
return $artist;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue