Merge pull request #48 from creative-commoners/pulls/2.0/fix-cache-api

FIX Use correct CacheInterface API methods and remove doubled up logic
This commit is contained in:
Dylan Wagstaff 2018-04-06 11:57:18 +12:00 committed by GitHub
commit 3ff01bf9e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 10 deletions

View File

@ -54,22 +54,15 @@ class CurlLinkChecker implements LinkChecker
return null;
}
$cacheKey = md5($href);
if (!$this->config()->get('bypass_cache')) {
// Check if we have a cached result
$cacheKey = md5($href);
$result = $this->getCache()->load($cacheKey);
$result = $this->getCache()->get($cacheKey, false);
if ($result !== false) {
return $result;
}
}
// Check if we have a cached result
$cacheKey = md5($href);
$result = $this->getCache()->get($cacheKey, false);
if ($result !== false) {
return $result;
}
// No cached result so just request
$handle = curl_init($href);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
@ -84,7 +77,7 @@ class CurlLinkChecker implements LinkChecker
if (!$this->config()->get('bypass_cache')) {
// Cache result
$this->getCache()->save($httpCode, $cacheKey);
$this->getCache()->set($cacheKey, $httpCode);
}
return $httpCode;
}