Route cache

This commit is contained in:
2021-01-30 17:17:47 +05:00
parent 1d4ac145a4
commit c0ae632fdc

View File

@@ -8,6 +8,7 @@ use App\Http\Controllers\API\TopicsAPIController;
use App\Http\Controllers\API\MyListAPIController; use App\Http\Controllers\API\MyListAPIController;
use App\Http\Controllers\API\NewsLetterAPIController; use App\Http\Controllers\API\NewsLetterAPIController;
use App\Article; use App\Article;
use Illuminate\Support\Facades\Cache;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -38,6 +39,7 @@ Route::post('newsletter/subscribe', [NewsLetterAPIController::class, 'store'])->
Route::get('/ping/{source}', \API\MonitorAPIController::class); Route::get('/ping/{source}', \API\MonitorAPIController::class);
Route::get('/latest/webhook', function () { Route::get('/latest/webhook', function () {
return Cache::remember('webhooks.latest', 60, function () {
return Article::latest()->limit(20)->get()->transform(function ($article) { return Article::latest()->limit(20)->get()->transform(function ($article) {
return [ return [
"id" => $article->id, "id" => $article->id,
@@ -51,3 +53,4 @@ Route::get('/latest/webhook', function(){
]; ];
}); });
}); });
});