Files
HeimerdingerLoL/app/Http/Controllers/StreamerController.php
Rico van Zelst 7ccd8ba022 feat: Add caching to streamer data retrieval
- Added caching mechanism to store and retrieve streamer data for API responses, improving performance.
- Implemented cache forget method in StreamerPanelController for CRUD operations to update cached data accordingly.
2024-03-26 10:30:09 +01:00

39 lines
733 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Streamer;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class StreamerController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Display the specified resource.
*/
public function show(Streamer $streamer)
{
//
}
/**
* API: JSON response of all streamers.
* Data is cached for 12 hours.
*/
public function all()
{
$streamers = Cache::remember('streamersListAllAPICache', 60 * 60 * 12, static fn () => Streamer::orderBy('champion_id')->get());
return response()->json($streamers);
}
}