Skip to content

Commit

Permalink
build(core): laravel 10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
StivenKatuuk authored and jdavidbakr committed Oct 31, 2023
1 parent db237bb commit c6af14b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor
composer.lock
.idea
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
}
],
"require": {
"illuminate/support": "8.*|9.*",
"illuminate/support": "8.*|9.*|10.*",
"php": ">=7.1.0",
"mockery/mockery": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "9.*",
"phpunit/phpunit": "9.*|10.*",
"squizlabs/php_codesniffer": "~2.3",
"orchestra/testbench": "6.*|7.*"
"orchestra/testbench": "6.*|7.*|8.*"
},
"autoload": {
"psr-4": {
Expand All @@ -42,4 +42,4 @@
"dev-master": "1.0-dev"
}
}
}
}
17 changes: 8 additions & 9 deletions src/LaravelCacheGarbageCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,37 @@ public function handle()
'driver'=>'local',
'root'=>config('cache.stores.file.path')
];

Config::set('filesystems.disks.fcache', $cacheDisk);

$expired_file_count = 0;
$active_file_count = 0;

// Grab the cache files
$files = Storage::disk('fcache')->allFiles();

// Loop the files and get rid of any that have expired
foreach ($files as $key=>$cachefile) {
// Ignore this file
if ($cachefile == '.gitignore') {
continue;
}

try {
// Grab the contents of the file
$contents = Storage::disk('fcache')->get($cachefile);

// Get the expiration time
$expire = substr($contents, 0, 10);

// See if we have expired
if (Carbon::now()->timestamp >= $expire) {
// Delete the file
Storage::disk('fcache')->delete($cachefile);

$expired_file_count++;
} else {
$active_file_count++;

continue;
}

$active_file_count++;
} catch (FileNotFoundException $e) {
// Getting an occasional error of this type on the 'get' command above,
// so adding a try-catch to skip the file if we do.
continue;
}
}
}
Expand Down

0 comments on commit c6af14b

Please sign in to comment.