From d78f7c7734b5bddfe75131334372f121a99b6c92 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 13 May 2019 20:26:52 -0600 Subject: [PATCH] Update ApiController --- app/Http/Controllers/ApiController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index 95bf0f6db..1a0e888b5 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -9,8 +9,7 @@ use App\{ Profile, UserFilter }; -use Auth; -use Cache; +use Auth, Cache, Redis; use Illuminate\Http\Request; use App\Services\SuggestionService; @@ -71,6 +70,13 @@ class ApiController extends BaseApiController ->pluck('filterable_id')->toArray(); $following = array_merge($following, $filters); + $key = config('cache.prefix').':api:local:exp:rec:'.$id; + $ttl = (int) Redis::ttl($key); + + if($request->filled('refresh') == true && (290 > $ttl) == true) { + Cache::forget('api:local:exp:rec:'.$id); + } + $res = Cache::remember('api:local:exp:rec:'.$id, now()->addMinutes(5), function() use($id, $following, $ids) { return Profile::select( 'id',