From 84f4e88573099a0548636235866be1bdd63918fb Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 14 Nov 2023 23:55:53 -0700 Subject: [PATCH] Update HashtagFollowService, fix cache invalidation bug --- app/Services/HashtagFollowService.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Services/HashtagFollowService.php b/app/Services/HashtagFollowService.php index 012c8c00a..d4f93f404 100644 --- a/app/Services/HashtagFollowService.php +++ b/app/Services/HashtagFollowService.php @@ -24,12 +24,7 @@ class HashtagFollowService public static function unfollow($hid, $pid) { - $list = self::getPidByHid($hid); - if($list && count($list)) { - $list = array_values(array_diff($list, [$pid])); - Cache::put(self::FOLLOW_KEY . $hid, $list, 86400); - } - return; + return Redis::zrem(self::CACHE_KEY . $hid, $pid); } public static function add($hid, $pid) @@ -67,7 +62,7 @@ class HashtagFollowService public static function isWarm($hid) { - return Redis::zcount($hid, 0, -1) ?? Redis::zscore(self::CACHE_WARMED, $hid) != null; + return Redis::zcount(self::CACHE_KEY . $hid, 0, -1) ?? Redis::zscore(self::CACHE_WARMED, $hid) != null; } public static function setWarm($hid)