Jelajahi Sumber

Update PublicApiController

Daniel Supernault 6 tahun lalu
induk
melakukan
3b7802814d
1 mengubah file dengan 4 tambahan dan 2 penghapusan
  1. 4 2
      app/Http/Controllers/PublicApiController.php

+ 4 - 2
app/Http/Controllers/PublicApiController.php

@@ -305,8 +305,10 @@ class PublicApiController extends Controller
         // $timeline = Timeline::build()->local();
         // $timeline = Timeline::build()->local();
         $pid = Auth::user()->profile->id;
         $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');
         $private = Profile::whereIsPrivate(true)->orWhereNotNull('status')->where('id', '!=', $pid)->pluck('id');
         $filters = UserFilter::whereUserId($pid)
         $filters = UserFilter::whereUserId($pid)