Update ApiV1Controller, invalidate status reply cache on new reply

This commit is contained in:
Daniel Supernault 2022-01-27 00:39:44 -07:00
parent 3d86d21be6
commit 3c261bbfec
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -2110,6 +2110,7 @@ class ApiV1Controller extends Controller
$status->in_reply_to_profile_id = $parent->profile_id; $status->in_reply_to_profile_id = $parent->profile_id;
$status->save(); $status->save();
StatusService::del($parent->id); StatusService::del($parent->id);
Cache::forget('status:replies:all:' . $parent->id);
} }
if($ids) { if($ids) {
@ -2519,6 +2520,13 @@ class ApiV1Controller extends Controller
$sortBy = $request->input('sort', 'all'); $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')) { if($sortBy == 'all' && !$request->has('cursor')) {
$ids = Cache::remember('status:replies:all:' . $id, 86400, function() use($id) { $ids = Cache::remember('status:replies:all:' . $id, 86400, function() use($id) {
return DB::table('statuses') return DB::table('statuses')