Calling a method after laravel cache storage expires

82 Views Asked by At

I want to set cache storage, for example for 10 minutes

and after 10 minutes so that the cache is not only cleared, but also calls the method

is it possible to do this with laravel cache?

thx for answers

1

There are 1 best solutions below

0
Gündoğdu Yakıcı On

You can prepare a url like this.

Route::get('/clear-cache', function() {
    $exitCode = Artisan::call('cache:clear');
    return "Cache is cleared";
});

You can then run a cron job like this.

*/5 * * * * wget https://example.com/clear-cache

You can get more information by clicking the link.