Command to delete old expired cache files.
When using the file cache driver, Laravel creates the cache files but never purges expired ones. This can lead to a situation where you have a large number of unused and irrelevant cache files, especially if you do a lot of short-term caching in your system.
Copy the CacheGarbageCollector.php
file to app/console/Commands/
php artisan cache:gc
To schedule this command to be executed daily add this line in app/Console/Kernel.php
.
$schedule->command('cache:gc')->dailyAt('4:00');
Inspired by jdavidbakr/laravel-cache-garbage-collector. The Main difference is this commad only reads the first 10 bytes of the file so you save time with big cache files and the command has a progress bar.