laravel delete cache keys like code example

Example 1: clear cache in laravel without artisan

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

Example 2: laravel cache

Cache::put('key', 'value', $seconds);
Cache::rememberForever('users', function () {
    return DB::table('users')->get();
}); 
Cache::get('key');
Cache::has('key');
Cache::pull('key');

Example 3: clear cache in laravel without artisan

Route::get('/route-cache', function() {
     $exitCode = Artisan::call('route:cache');
     return 'Routes cache cleared';
 });

Tags:

Php Example