Преглед изворни кода

Update FollowerService, add quickCheck to follows method for non cold-boot checks

Daniel Supernault пре 1 година
родитељ
комит
d3f032b2ec
1 измењених фајлова са 5 додато и 1 уклоњено
  1. 5 1
      app/Services/FollowerService.php

+ 5 - 1
app/Services/FollowerService.php

@@ -89,12 +89,16 @@ class FollowerService
         return Redis::zCard(self::FOLLOWING_KEY . $id);
     }
 
-    public static function follows(string $actor, string $target)
+    public static function follows(string $actor, string $target, $quickCheck = false)
     {
         if($actor == $target) {
             return false;
         }
 
+        if($quickCheck) {
+            return (bool) Redis::zScore(self::FOLLOWERS_KEY . $target, $actor);
+        }
+
         if(self::followerCount($target, false) && self::followingCount($actor, false)) {
             self::cacheSyncCheck($target, 'followers');
             return (bool) Redis::zScore(self::FOLLOWERS_KEY . $target, $actor);