From 392f9ffd69fadc5a02e17f0e82689584512f3fe8 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Sun, 14 Feb 2021 18:01:31 +0000 Subject: [PATCH] Shift Cache methods to use seconds To conform with PSR-16 Laravel 5.8 changed the cache expiration time from minutes to seconds. If you were passing an integer, Shift converted this to its integer equivalent in seconds. If you were passing a "minutes" variable, Shift converted this to the relative date time equivalent for readability. --- app/Http/Controllers/Api/Web/StatsController.php | 2 +- app/Models/Track.php | 2 +- app/Traits/TrackCollection.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/Web/StatsController.php b/app/Http/Controllers/Api/Web/StatsController.php index 68d0091a..c0ccb7ff 100644 --- a/app/Http/Controllers/Api/Web/StatsController.php +++ b/app/Http/Controllers/Api/Web/StatsController.php @@ -109,7 +109,7 @@ class StatsController extends ApiControllerBase public function getTrackStats($id) { - $cachedOutput = Cache::remember('track_stats'.$id, 5, function () use ($id) { + $cachedOutput = Cache::remember('track_stats'.$id, 300, function () use ($id) { try { $track = Track::published()->findOrFail($id); } catch (ModelNotFoundException $e) { diff --git a/app/Models/Track.php b/app/Models/Track.php index 70f5e124..dace9624 100644 --- a/app/Models/Track.php +++ b/app/Models/Track.php @@ -387,7 +387,7 @@ class Track extends Model implements Searchable, Commentable, Favouritable { $trackData = Cache::remember( 'popular_tracks'.$count.'-'.($allowExplicit ? 'explicit' : 'safe'), - 5, + 300, function () use ($allowExplicit, $count, $skip) { /*$query = static ::published() diff --git a/app/Traits/TrackCollection.php b/app/Traits/TrackCollection.php index b6376ee1..b81a6f42 100644 --- a/app/Traits/TrackCollection.php +++ b/app/Traits/TrackCollection.php @@ -170,7 +170,7 @@ trait TrackCollection return 0; } - return Cache::remember($this->getCacheKey('filesize-'.$format), 1440, function () use ($tracks, $format) { + return Cache::remember($this->getCacheKey('filesize-'.$format), 86400, function () use ($tracks, $format) { $size = 0; // Check whether the format is lossless yet not all master files are lossless