From d3f032b2ec1cbef33066ec131961eb31dc4a76b6 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 16 Dec 2023 06:11:13 -0700 Subject: [PATCH] Update FollowerService, add quickCheck to follows method for non cold-boot checks --- app/Services/FollowerService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Services/FollowerService.php b/app/Services/FollowerService.php index 8b5eeced9..dcb7a1158 100644 --- a/app/Services/FollowerService.php +++ b/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);