0.1.4
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user