From 3c261bbfec99aeae1491f77851102e7cd51271fa Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 27 Jan 2022 00:39:44 -0700 Subject: [PATCH] Update ApiV1Controller, invalidate status reply cache on new reply --- app/Http/Controllers/Api/ApiV1Controller.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index e7415bebe..9236c9086 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2110,6 +2110,7 @@ class ApiV1Controller extends Controller $status->in_reply_to_profile_id = $parent->profile_id; $status->save(); StatusService::del($parent->id); + Cache::forget('status:replies:all:' . $parent->id); } if($ids) { @@ -2519,6 +2520,13 @@ class ApiV1Controller extends Controller $sortBy = $request->input('sort', 'all'); + if($sortBy == 'all' && $status['replies_count'] && $request->has('refresh_cache')) { + if(!Cache::has('status:replies:all-rc:' . $id)) { + Cache::forget('status:replies:all:' . $id); + Cache::put('status:replies:all-rc:' . $id, true, 300); + } + } + if($sortBy == 'all' && !$request->has('cursor')) { $ids = Cache::remember('status:replies:all:' . $id, 86400, function() use($id) { return DB::table('statuses')