jikan-rest/app/Contracts/CachedScraperService.php
pushrbx 49ebc8f581 wip - mediator refactor
- anime schedules - validation and corrections
- refactorings around "augmentResponse" - macro usage instead
2023-05-21 11:14:34 +01:00

37 lines
1.1 KiB
PHP

<?php
namespace App\Contracts;
use App\Support\CachedData;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Representation of a service which knows about cached MAL scraper results.
*/
interface CachedScraperService
{
/**
* Finds cached scraper results by cacheKey, if not found scrapes them from MAL via the provided callback.
* @param string $cacheKey
* @param \Closure $getMalDataCallback
* @param int|null $page
* @return CachedData
*/
public function findList(string $cacheKey, \Closure $getMalDataCallback, ?int $page = null): CachedData;
/**
* Finds cached scraper results by id in the database, if not found scrapes them from MAL.
* @param int $id
* @param string $cacheKey
* @return CachedData
* @throws NotFoundHttpException
*/
public function find(int $id, string $cacheKey): CachedData;
public function findByKey(string $key, mixed $val, string $cacheKey): CachedData;
public function get(string $cacheKey): CachedData;
}