diff --git a/app/Http/Controllers/FollowerController.php b/app/Http/Controllers/FollowerController.php index d0ebb5fc3..a2da37ec0 100644 --- a/app/Http/Controllers/FollowerController.php +++ b/app/Http/Controllers/FollowerController.php @@ -8,7 +8,7 @@ use App\{ Profile, UserFilter }; -use Auth; +use Auth, Cache; use Illuminate\Http\Request; use App\Jobs\FollowPipeline\FollowPipeline; @@ -67,5 +67,8 @@ class FollowerController extends Controller $follower = Follower::whereProfileId($user->id)->whereFollowingId($target->id)->firstOrFail(); $follower->delete(); } + + Cache::forget('profile:followers:'.$target->id); + Cache::forget('profile:following:'.$user->id); } } diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 510b15717..c3a734f19 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -305,8 +305,10 @@ class PublicApiController extends Controller // $timeline = Timeline::build()->local(); $pid = Auth::user()->profile->id; - $following = Follower::whereProfileId($pid)->pluck('following_id'); - $following->push($pid)->toArray(); + $following = Cache::remember('profile:following:'.$pid, 1440, function() use($pid) { + $following = Follower::whereProfileId($pid)->pluck('following_id'); + return $following->push($pid)->toArray(); + }); $private = Profile::whereIsPrivate(true)->orWhereNotNull('status')->where('id', '!=', $pid)->pluck('id'); $filters = UserFilter::whereUserId($pid)