Skip to content

Commit

Permalink
Set a cache driver to prevent non-supportive tag driver errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Jan 6, 2023
1 parent 9587720 commit eb0ff3d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ This will be the contents of the published config file:

```php
return [
/*
|--------------------------------------------------------------------------
| Cache
|--------------------------------------------------------------------------
|
| The following array lists the cache options for the application.
|
*/
'cache' => [
// Only drivers that support tags are supported.
// These are: array, memcached and redis.
'driver' => 'array',
],

/*
|--------------------------------------------------------------------------
| Check classes
Expand Down Expand Up @@ -97,7 +111,7 @@ return [
|
*/
'check_paths' => [
'Vormkracht10\\Seo\\Checks' => base_path('vendor/vormkracht10/laravel-seo-scanner/src/Checks'),
'Vormkracht10\\Seo\\Checks' => base_path('vendor/vormkracht10/laravel-seo-scanner-scanner/src/Checks'),
],

/*
Expand Down
16 changes: 15 additions & 1 deletion config/seo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Cache
|--------------------------------------------------------------------------
|
| The following array lists the cache options for the application.
|
*/
'cache' => [
// Only drivers that support tags are supported.
// These are: array, memcached and redis.
'driver' => 'array',
],

/*
|--------------------------------------------------------------------------
| Check classes
Expand Down Expand Up @@ -31,7 +45,7 @@
|
*/
'check_paths' => [
'Vormkracht10\\Seo\\Checks' => base_path('vendor/vormkracht10/laravel-seo/src/Checks'),
'Vormkracht10\\Seo\\Checks' => base_path('vendor/vormkracht10/laravel-seo-scanner/src/Checks'),
],

/*
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/SeoScan.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function handle(): int

$this->info('Command completed with '.$this->failed.' failed and '.$this->success.' successful checks on '.$totalPages.' pages.');

cache()->tags('seo')->flush();
cache()->driver(config('seo.cache.driver'))->tags('seo')->flush();

if (config('seo.database.save')) {
$scan->update([
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/SeoScanUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function handle(): int
$this->info('Completed '.$totalChecks.' out of '.getCheckCount().' checks.');
$this->line('');

cache()->tags('seo')->flush();
cache()->driver(config('seo.cache.driver'))->tags('seo')->flush();

return self::SUCCESS;
}
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function isBrokenLink(string $url): bool
if (! function_exists('getRemoteStatus')) {
function getRemoteStatus(string $url): int
{
return cache()->tags('seo')->rememberForever($url, function () use ($url) {
return cache()->driver(config('seo.cache.driver'))->tags('seo')->rememberForever($url, function () use ($url) {
$ch = curl_init($url);

$options = [
Expand All @@ -46,7 +46,7 @@ function getRemoteStatus(string $url): int
if (! function_exists('getRemoteFileSize')) {
function getRemoteFileSize(string $url): int
{
return cache()->tags('seo')->rememberForever($url.'.size', function () use ($url) {
return cache()->driver(config('seo.cache.driver'))->tags('seo')->rememberForever($url.'.size', function () use ($url) {
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_NOBODY, true);
Expand Down

0 comments on commit eb0ff3d

Please sign in to comment.