This commit is contained in:
User
2025-01-21 19:57:07 -05:00
parent befc90dd02
commit d9f57e4e86
17 changed files with 206 additions and 230 deletions

View File

@@ -123,19 +123,24 @@ class CopyManga
* @param string $method
* @param string $userAgent
* @param int $ttl
* @param bool $force
* @return mixed|string
* @throws GuzzleException
*/
protected function execute(string $url, string $method = 'GET', string $userAgent = "", int $ttl = 0): mixed
protected function execute(string $url, string $method = 'GET', string $userAgent = "", int $ttl = 0, bool $force = false): mixed
{
if ($this->options['caching']) {
// Check cache exist
if (Cache::has("URL_{$url}")) {
$cache = Cache::get("URL_{$url}");
if (isset($cache['type']) && $cache['type'] == 'HTML') {
return $cache['response'];
} else {
return $cache;
if ($force) {
$this->forget($url);
} else {
if ($this->options['caching']) {
// Check cache exist
if (Cache::has("URL_{$url}")) {
$cache = Cache::get("URL_{$url}");
if (isset($cache['type']) && $cache['type'] == 'HTML') {
return $cache['response'];
} else {
return $cache;
}
}
}
}
@@ -178,6 +183,17 @@ class CopyManga
}
}
/**
* Remove a cache with key
*
* @param string $url
* @return void
*/
public function forget(string $url): void
{
Cache::forget("URL_{$url}");
}
/**
* Get tags available
*
@@ -256,16 +272,17 @@ class CopyManga
* @param int $offset
* @param array $parameters
* @param string $group
* @param bool $force
* @return mixed|string
* @throws GuzzleException
*/
public function chapters(string $comic, int $limit = 200, int $offset = 0, array $parameters = [], string $group = "default"): mixed
public function chapters(string $comic, int $limit = 200, int $offset = 0, array $parameters = [], string $group = "default", bool $force = false): mixed
{
$parameters['limit'] = $limit;
$parameters['offset'] = $offset;
$options = $this->execute($this->buildUrl("comic/{$comic}/group/{$group}/chapters", $parameters, false), 'OPTIONS');
return $this->execute($this->buildUrl("comic/{$comic}/group/{$group}/chapters", $parameters), ttl: 24 * 60 * 60);
return $this->execute($this->buildUrl("comic/{$comic}/group/{$group}/chapters", $parameters), ttl: 24 * 60 * 60, force: $force);
}
/**