coryd.dev/api/Classes/BookFetcher.php

19 lines
390 B
PHP

<?php
namespace App\Classes;
class BookFetcher extends PageFetcher
{
public function fetch(string $url): ?array
{
$cacheKey = "book_" . md5($url);
$cached = $this->cacheGet($cacheKey);
if ($cached) return $cached;
$book = $this->fetchSingleFromApi("optimized_books", $url);
if (!$book) return null;
$this->cacheSet($cacheKey, $book);
return $book;
}
}