diff --git a/app/Http/Controllers/DownloadController.php b/app/Http/Controllers/DownloadController.php index 80142c4..a6ae9a7 100644 --- a/app/Http/Controllers/DownloadController.php +++ b/app/Http/Controllers/DownloadController.php @@ -5,6 +5,7 @@ use App\Helpers; use App\Models\Upload; use App\Http\Requests; +use Cache; use DB; use Illuminate\Http\Request; use Log; @@ -22,7 +23,11 @@ public function get(Request $request, Upload $upload) } if (!$request->user() || $request->user()->id !== $upload->user_id) { - DB::table('uploads')->where('id', $upload->id)->increment('views'); + $cacheKey = 'cached_view:' . $request->getClientIp(); + if (!Cache::has($cacheKey)) { + Cache::put($cacheKey, 1, 60); + DB::table('uploads')->where('id', $upload->id)->increment('views'); + } } return Helpers::sendFile($upload);