Skip to content

Commit

Permalink
Add caching to overall appData JSON output [MA-159]
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Feb 26, 2024
1 parent d16c2a0 commit 629db7c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use App\Http\Controllers\Api\TourCategories;
use App\Http\Controllers\Api\Tours;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Cache;

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -42,10 +43,12 @@
Data::class,
Search::class,
]);
return $controllers->reduce(function ($output, $controller) {
// Instantiate and invoke each controller, then merge into the output
return $output->merge((new $controller())());
}, collect());
return Cache::remember('apiData', 3600, function () use ($controllers) { // 3600 = 1 hour
return $controllers->reduce(function ($output, $controller) {
// Instantiate and invoke each controller, then merge into the output
return $output->merge((new $controller())());
}, collect());
});
});
Route::get('/audio_files', AudioFiles::class)->name('audio_files');
Route::get('/dashboard', Dashboard::class)->name('dashboard');
Expand Down

0 comments on commit 629db7c

Please sign in to comment.